.cpp to .pyd

V

vedrandekovic

Hello,

I want to build my C++ (.cpp) script to (.pyd) like this:

http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C++

I have installed "Microsoft Visual studio .NET 2003" and "Boost
Python" and then after I run my setup script:

python setup.py build


I get this error:


running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
/MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
\Panda3D-1.5.2\pytho
n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2

I think that my MS visual studio cannot find "boost python", if
that's the problem then can you tell me how can I solve it.
This is very begginer question,but I can't find answer nowhere, and I
don't have any expirience with Microsoft products.


Sorry for my bad english!
Regards,
Veki
 
M

Matthieu Brucher

I think that my MS visual studio cannot find "boost python", if
that's the problem then can you tell me how can I solve it.
This is very begginer question,but I can't find answer nowhere, and I
don't have any expirience with Microsoft products.

Hi,

Put Boost in your include path (options of Visual Studio).

Matthieu
 
V

vedrandekovic

Hi,

Put Boost in your include path (options of Visual Studio).

Matthieu
--
French PhD student
Website :http://matthieu-brucher.developpez.com/
Blogs :http://matt.eifelle.comandhttp://blog.developpez.com/?blog=92
LinkedIn :http://www.linkedin.com/in/matthieubrucher

Hello again,

Thanks for your quick reply!
Put Boost in your include path (options of Visual Studio).

Look at my image:
http://img225.imageshack.us/my.php?image=zaimghostfy1.png

I still get the same error.

Regards,
Veki
 
U

Ulrich Eckhardt

hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/module.hpp': No such file or directory

You need to tell it where to find the Boost includes. I suggest you first
try to get some header-only Boost library going as example, if you have
that right, you also have the include paths right.

In your second posting, you gave a link to a picture which had the exact
right dialog for setting this as system setup. You can also set the path on
a per-project base, then it's in the C++ settings.

Note that for compiled libraries like Boost.Python you will first have to
compile those (see Boost docs), put the DLLs into a place where they can be
found (e.g. the windows dir or anything else on the path) and also have to
set a path to the .LIBS in the linker settings.

As an alternative to compiling libraries separately, you can also include
the Boost sources into your project, just add BOOST_PYTHON_STATIC_LIB to
the preprocessor defines and include the following files from one(!)
translation unit:

<boost/../libs/python/src/module.cpp>
<boost/../libs/python/src/dict.cpp>
<boost/../libs/python/src/errors.cpp>
<boost/../libs/python/src/list.cpp>
<boost/../libs/python/src/object_operators.cpp>
<boost/../libs/python/src/object_protocol.cpp>
<boost/../libs/python/src/tuple.cpp>
<boost/../libs/python/src/str.cpp>
<boost/../libs/python/src/object/class.cpp>
<boost/../libs/python/src/object/function.cpp>
<boost/../libs/python/src/object/inheritance.cpp>
<boost/../libs/python/src/object/pickle_support.cpp>
<boost/../libs/python/src/converter/builtin_converters.cpp>
<boost/../libs/python/src/converter/registry.cpp>
<boost/../libs/python/src/converter/from_python.cpp>

Note: this is with Boost 1.33.1, newer versions likely differ.


Uli
 
K

Kay Schluehr

It doesn't look like a VS issue since you've started the setup.py
script that calls the command line compiler. So I'd expect it behaves
not different from other command line tools and you might have to add
the boost path directly to the command-line options.
 
V

vedrandekovic

You need to tell it where to find the Boost includes. I suggest you first
try to get some header-only Boost library going as example, if you have
that right, you also have the include paths right.

In your second posting, you gave a link to a picture which had the exact
right dialog for setting this as system setup. You can also set the path on
a per-project base, then it's in the C++ settings.

Note that for compiled libraries like Boost.Python you will first have to
compile those (see Boost docs), put the DLLs into a place where they can be
found (e.g. the windows dir or anything else on the path) and also have to
set a path to the .LIBS in the linker settings.

As an alternative to compiling libraries separately, you can also include
the Boost sources into your project, just add BOOST_PYTHON_STATIC_LIB to
the preprocessor defines and include the following files from one(!)
translation unit:

<boost/../libs/python/src/module.cpp>
<boost/../libs/python/src/dict.cpp>
<boost/../libs/python/src/errors.cpp>
<boost/../libs/python/src/list.cpp>
<boost/../libs/python/src/object_operators.cpp>
<boost/../libs/python/src/object_protocol.cpp>
<boost/../libs/python/src/tuple.cpp>
<boost/../libs/python/src/str.cpp>
<boost/../libs/python/src/object/class.cpp>
<boost/../libs/python/src/object/function.cpp>
<boost/../libs/python/src/object/inheritance.cpp>
<boost/../libs/python/src/object/pickle_support.cpp>
<boost/../libs/python/src/converter/builtin_converters.cpp>
<boost/../libs/python/src/converter/registry.cpp>
<boost/../libs/python/src/converter/from_python.cpp>

Note: this is with Boost 1.33.1, newer versions likely differ.

Uli

Hello again,

This answer is probably exactly what I need, but as I said, I don't
have any expirience with MS products! Is there any other easier
way except "boost python" to make .pyd from .cpp?
 
C

Carl Banks

Hello,

I want to build my C++ (.cpp) script to (.pyd) like this:

http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C++

I have installed "Microsoft Visual studio .NET 2003" and "Boost
Python" and then after I run my setup script:

python setup.py build

I get this error:

running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
 /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
\Panda3D-1.5.2\pytho
n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2

I think that my MS visual studio  cannot find "boost python", if
that's the problem then can you tell me how can I solve it.
This is very begginer question,but I can't find answer nowhere, and I
don't have any expirience with Microsoft products.

Sorry for my bad english!
Regards,
Veki


First, locate the boost header files. Suppose you find the file
module.hpp in this location:

C:\boost-whatever-version\include\boost\python\module.hpp


The part that comes before boost\python\module.hpp is the required
include directory. You can tell setup to use this directory by adding
the following argument to the Extension call:

include_dirs = ['C:\\boost-whatever-version\\include']

Notice the doubling of backslashes. Remember to add the directory
where the boost header files lie on your system; don't add this line
exactly.

You should end up with a setup call that looks like this:

setup(name="blah",
ext_modules=[
Extension("hello", ["hellomodule.cpp"],
libraries = ["boost_python"],
include_dirs = ['C:\\boost-whatever-version\\include'])
])



Carl Banks
 
K

Kay Schluehr

I want to build my C++ (.cpp) script to (.pyd) like this:

I have installed "Microsoft Visual studio .NET 2003" and "Boost
Python" and then after I run my setup script:
python setup.py build
I get this error:
running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
/MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
\Panda3D-1.5.2\pytho
n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2
I think that my MS visual studio cannot find "boost python", if
that's the problem then can you tell me how can I solve it.
This is very begginer question,but I can't find answer nowhere, and I
don't have any expirience with Microsoft products.
Sorry for my bad english!
Regards,
Veki

First, locate the boost header files. Suppose you find the file
module.hpp in this location:

C:\boost-whatever-version\include\boost\python\module.hpp

The part that comes before boost\python\module.hpp is the required
include directory. You can tell setup to use this directory by adding
the following argument to the Extension call:

include_dirs = ['C:\\boost-whatever-version\\include']

Notice the doubling of backslashes. Remember to add the directory
where the boost header files lie on your system; don't add this line
exactly.

You should end up with a setup call that looks like this:

setup(name="blah",
ext_modules=[
Extension("hello", ["hellomodule.cpp"],
libraries = ["boost_python"],
include_dirs = ['C:\\boost-whatever-version\\include'])
])

Carl Banks

One can omit double backslashes when prefixing by 'r' or 'R':

r'C:\boost-whatever-version\include'

Python is just too kind.
 
V

vedrandekovic

I want to build my C++ (.cpp) script to (.pyd) like this:

I have installed "Microsoft Visual studio .NET 2003" and "Boost
Python" and then after I run my setup script:
python setup.py build
I get this error:
running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
 /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
\Panda3D-1.5.2\pytho
n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2
I think that my MS visual studio  cannot find "boost python", if
that's the problem then can you tell me how can I solve it.
This is very begginer question,but I can't find answer nowhere, and I
don't have any expirience with Microsoft products.
Sorry for my bad english!
Regards,
Veki

First, locate the boost header files.  Suppose you find the file
module.hpp in this location:

C:\boost-whatever-version\include\boost\python\module.hpp

The part that comes before boost\python\module.hpp is the required
include directory.  You can tell setup to use this directory by adding
the following argument to the Extension call:

include_dirs = ['C:\\boost-whatever-version\\include']

Notice the doubling of backslashes.  Remember to add the directory
where the boost header files lie on your system; don't add this line
exactly.

You should end up with a setup call that looks like this:

setup(name="blah",
    ext_modules=[
        Extension("hello", ["hellomodule.cpp"],
            libraries = ["boost_python"],
            include_dirs = ['C:\\boost-whatever-version\\include'])
    ])

Carl Banks

Hi,

Thanks for quick reply.Maybe I'm crazy but I did what you said and I
stll get the same error :( :( :( :(.I have boost version 1.34.1 and
I'm
running it on Windows XP SP2.

Regards,
Veki
 
C

Carl Banks

Thanks for quick reply.Maybe I'm crazy but I did what you said and I
stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
I'm
running it on Windows XP SP2.


If you had done what I said you wouldn't have gotten the "same error";
if nothing else there would be some small changes in the output that
could give us a better understanding of what's wrong.

So even if it is the same error message, unless you know for a fact
that every last byte of output is exactly the same, please post it.


Carl Banks
 
C

Carl Banks

Thanks for quick reply.Maybe I'm crazy but I did what you said and I
stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
I'm
running it on Windows XP SP2.

While you're at it, please post your setup.py

Carl Banks
 
V

vedrandekovic

While you're at it, please post your setup.py

Carl Banks

Hi,

Here is my setup.py script:

setup(name="MyApp",
ext_modules=[
Extension("hello", ["hellomodule.cpp"],
libraries = ["boost_python"],
include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\
\boost'],
)
])

Regards,
Veki
 
V

vedrandekovic

On Aug 8, 1:11 pm, (e-mail address removed) wrote:
While you're at it, please post your setup.py
Carl Banks

Hi,

Here is my setup.py script:

setup(name="MyApp",
    ext_modules=[
        Extension("hello", ["hellomodule.cpp"],
            libraries = ["boost_python"],
            include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\
\boost'],
            )
    ])

Regards,
Veki

Hello,

...and here is the error:

C:\Panda3D-1.5.2\python\Lib\site-packages>python setup.py build
running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
/MD /W3 /GX /DNDEBUG "-ID:\Program Files\boost\boost_1_34_1\boost" -
IC:\Panda3D
-1.5.2\python\include -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.cpp /
Fobuild\t
emp.win32-2.5\Release\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2

C:\Panda3D-1.5.2\python\Lib\site-packages>pause
Press any key to continue . . .
 
C

Carl Banks

Here is my setup.py script:
setup(name="MyApp",
    ext_modules=[
        Extension("hello", ["hellomodule.cpp"],
            libraries = ["boost_python"],
            include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\
\boost'],
            )
    ])
Regards,
Veki

Hello,

...and here is the error:

C:\Panda3D-1.5.2\python\Lib\site-packages>python setup.py build
running build
running build_ext
building 'hello' extension
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
 /MD /W3 /GX /DNDEBUG "-ID:\Program Files\boost\boost_1_34_1\boost" -

Good, it's included the directory you specified.
IC:\Panda3D
-1.5.2\python\include -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.cpp /
Fobuild\t
emp.win32-2.5\Release\hellomodule.obj
hellomodule.cpp
hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
'boost/python/
module.hpp': No such file or directory

But the file is not located there.
error: command '"D:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe"' failed with exit status 2

C:\Panda3D-1.5.2\python\Lib\site-packages>pause
Press any key to continue . . .

Ok, you have your include directory:

D:\Program Files\boost\boost_1_34_1\boost

And the file it's trying to access:

boost\python\module.hpp

The compiler tries to join the two when searching for the file to
include, like so:

D:\Program Files\boost\boost_1_34_1\boost\boost\python\module.hpp

Does this file exist on your system? Probably not. What you probably
did was to include the top boost directory in your setup.py when you
should have left it out like this:

include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1']

If that doesn't work, find the file "module.hpp", take the complete
pathname, remove the boost\python\module.hpp part, and use that as the
include_dir.


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top