building pyd files

Started by
8 comments, last by atcdevil 20 years ago
I am trying to get Visual Studio to build a .pyd file to import into python. Let''s say using the example here So far, I have created an empty Win32 DLL project, link with boost_python.lib, copy and pasted the code from the sample in, and built it. This results in a .dll and a .lib file. What am I missing? Thanks, Andrew
Advertisement
Well, that code alone has no way of telling Visual Studio to create a .pyd. Try renaming the created dll to a pyd; you may be pleasantly surprised to find that it works.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
when i ran python and used the import command, it didn''t recognize the pyd file
read the boost.python docs
http://www.boost.org/libs/python/doc/tutorial/doc/building_hello_world.html
The gist of it is that you need to compile using bjam, which invokes msvc for you.

[edited by - thedustbustr on March 19, 2004 10:31:09 PM]
But in the end, a pyd is actually just a renamed dll on Windows. So if it doesn''t work, something else is probably built wrongly. Maybe the entry point is not defined or something.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
quote:Original post by thedustbustr
read the boost.python docs
http://www.boost.org/libs/python/doc/tutorial/doc/building_hello_world.html
The gist of it is that you need to compile using bjam, which invokes msvc for you.

[edited by - thedustbustr on March 19, 2004 10:31:09 PM]


quote: subproject libs/python/example/tutorial ;

SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
include python.jam ;

extension hello # Declare a Python extension called hello
: hello.cpp # source
../../build/boost_python # dependencies
;


This jamfile confuses me.
What does the first line do, since my project isn''t a subproject of boost. Can I just remove it?

The jamfile also builds boost_python.dll. How do I make it not do that, since I have already built this dll, and I don''t want to waste time doing that, every time I build my project?

I still haven''t been able to compile it with a jamfile. Can anyone can offer a simpler example unlike what comes with boost python. That''s all I really need is just an example. that actually works.

Thanks,
Andrew
Although this is quite annoying, I copied my source as hello.cpp into the libs\python\example\tutorial build it using the sample jamfile and then copy over the pyd file to my python directory to test it. It does build except when I include files from other directories

So I need to set include and library directories, like the equivalent of -I and -L from make (I finally got comfortable using that program, and now someone's got to switch it up on me). I also need to link with specific libraries, the equivalent of -l. I've been searching the web for a few hours and cannot find ANYTHING (grrr) on how to do this. Does anyone have an example?

btw...
In my old makefile I had the following:
LIBRARIES	= -lIrrlicht -lfmod -lGL -lXxf86vm -lXext -lX11 -lz -ljpeg INCLUDE_DIRS 	= -I/usr/include/irrlicht -I/usr/X11R6/includeLIB_DIRS	= -L/usr/X11R6/lib   

So those are the libraries, and directories I'll need.

So far for a jamfile I have:

subproject libs/python/example/tutorial ;SEARCH on python.jam = $(BOOST_BUILD_PATH) ;include python.jam ;extension hello:   hello.cpp                 	../../build/boost_python  	;   

Thanks a lot.


[edited by - atcdevil on March 28, 2004 1:26:26 PM]
IIRC, there is, in the boost python distribution, a zip file containing older stuff, which includes an example.

However, there is little need to use bjam to build your extension (I sure don''t), you''re MUCH better off using the distutils python module.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Thanks for the info, I would love to forget about bjam.

I''ll look into distutils

This topic is closed to new replies.

Advertisement