.cpp to .pyd
Carl Banks
pavlovevidence at gmail.com
Thu Aug 7 15:43:08 EDT 2008
On Aug 7, 3:25 am, vedrandeko... at yahoo.com wrote:
> Hello,
>
> I want to build my C++ (.cpp) script to (.pyd) like this:
>
> http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B
>
> 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
More information about the Python-list
mailing list