Some CC ++ codes need to be used in Python and do not want to be converted into python, so they are written as python extensions for calling, compiling python extension process system environment in VC6: VC6 + Python-2.5.4
1. download the Python-2.5.4 source code.
2. decompress the package and open D: \ Python-2.5.4 \ PC \ VC6 \ pcbuild. dsw, compile, and D: \ Python-2.5.4 \ PC \ VC6 \ to obtain python25.dll, python25_d.dll, python25.lib, and python25_d.lib.
3. use VC6 to create a dynamic link library project, copy D: \ Python-2.5.4 \ PC \ example_nt \ example. c to the project directory, and add it to the project.
4. set up the project.
The code is as follows:
Open tools-> options-> directories, add D: \ PYTHON-2.5.4 \ INCLUDE to program files, and add D: \ PYTHON-2.5.4 \ PC \ VC6 to Library files.
Open Progect-> Settings, change Win32 Debug-> Link-> Output file name to example_d.pyd, and change Win32 Release-> Link-> Output file name to example. pyd.
5. Compile.
6. try to call:
The code is as follows:
D: \ MY Project \ testpymodule \ Release> python
Python 2.5.4 (r254: 67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on
Win32
Type "help", "copyright", "credits" or "license" for more information.
>>> Import example
>>> Example. foo ()
Hello, world
>>>