compile.py create DLL with Visual C++
Jason Orendorff
jason at jorendorff.com
Mon Jan 7 18:43:44 EST 2002
> I am going crazy trying to find a simple VC++ project example of a
> Win32 DLL which is basically a "Hello World" demo.
Okay, 2 things:
1. What you really want is python's distutils.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66509
It's sweet. You need your source file and a quick setup.py file.
"python setup.py install" builds and installs your extension.
2. If you really need a VC project, just open VC++ and do
File > New > Project > Win32 Dynamic-Link Library.
Get rid of the auto-generated code (you can probably just
delete everything except the .c file) and put in your code.
Then go to
Project > Settings > C/C++ > Preprocessor
and add in the "Additional include directories" box, type in
your Python "Include" directory (you need the include files,
of course; you can get them from the Python source
distribution.) (While you're in here, you can turn off
precompiled headers. They're nothing but trouble.)
Then, do
Build > Set Active Configuration
and select the "Release" configuration. Unless you have a debug
version of Python installed somewhere (unlikely), you won't have
any use for a debug DLL.
I'm probably forgetting something, but that's how I started and
it worked out okay in the end.
Once you're done, copy the DLL from your Release directory to
someplace like C:\python22\lib\site-packages. You can rename it
from foomodule.dll to foomodule.pyd if you like.
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list