Compiling the Numbers example under Windows
From DANSE
For all those times Windows needs a helping hand, here's how to do it:
For working in Windows, it may be best to use MS Visual C++. Here's what you'd do to create a project and so on in VC7.
- From the Start page select New Project.
- From the Project Types, pick Visual C++ Projects, from the Templates, choose Win32 project. Fill in the name for your library.
- On the next window, pick Application Settings, and set Application Type to DLL.
- In the Solution Explorer,
- get rid of stdafx.cpp.
- right-click on the name of the project, and choose Properties.
- Under the C/C++/General folder, add the additional include directory in which your distribution's Python.h file resides.
- Under the Linker/General tab, set the output file to _your_project_name.dll. Note that everything up to the ".dll" must be the same as what follows "init" in the init_your_project_name function in the wrapper code. In the Numbers example, we called that function init_PyNumbers (it's the last function in the file). So the dll has to be called _PyNumbers.dll. If the name of the file and the init function don't agree, the interpreter will get lost.
- Under the Linker/Input tab, enter Python21.lib (that's for Python 2.1, enter the lib appropriate to your distribution.
- Under Tools/Options/Projects/VC++ Directories, in the upper right hand corner choose Show Directories for: Library files. Add the directory your Python library lives in, if it ain't there already. You could put your include directory here also, and you won't have to add to every project for the rest of your life.
- In Solution Explorer, delete your_project_name.cpp.
Now add in your files full of source code, wrapper code, etc. Build, and when the _your_project_name.dll sppears in the output directory, move it into your PYTHON_PATH, and enjoy.
