Put a few posts first
Https://eastlakeside.gitbooks.io/interpy-zh/content/c_extensions/swig.html
http://blog.csdn.net/a8572785/article/details/10427521
http://blog.csdn.net/marscrazy_90/article/details/14045683
Hybrid programming has a good balance of performance and development speed, and today we learned three ways Python calls C + + functions
Python uses the C + + extension library in three ways: 1. Use CType 2. Using SWGI 3. Using the PYTHON/C API
The previous two methods did not destroy the source file, and finally there is a way to use the Python struct inside the python.h, all the code is re-encoded, the code can be called Cython, this method is the most common, code efficiency is the highest
The first method uses CType to load DLL files, but for some variable types to be re-declared, such as float,double, if you call yourself
The second method is equivalent to using the SWGI library to generate middleware *.i for the source file, and then build the corresponding DLL file through C + + compilation, rename the DLL file to _*.pyd and then copy the _*.pyd and _.py files to the Python project directory for import to use.
Third method, re-encode the source code
The first and second methods in the PYTHON3.5+VS2015+SWIG3.0.12+WIN10 64-bit system environment are described in detail below
The first method, refer to http://blog.csdn.net/marscrazy_90/article/details/14045683
The second method, refer to http://blog.csdn.net/a8572785/article/details/10427521, but remember to choose release x64 when compiling the DLL and the project----Properties-->c+ +--> python35.lib Python3.lib and other library file names in the linker-to-input entry
At the same time there are two ways to add a library file, the first is to add the directory and library directories in the VC + + directory of the project properties and fill in the file name in the projects----Property-->c++--> linker-----input-to-add dependency item
The second method is to add a C + + directory
Add Project header file directory: Project---Properties---configuration properties---c/C + +---General---Additional Include Directories: Plus header files to store directories.
B. The Lib Static library path for adding file references: Project---Properties---configuration PROPERTIES---linker---general---Additional Library directories: plus lib file directory.
C then add the project reference to the Lib file name: Project---Properties---configuration PROPERTIES---linker---input---Additional dependencies: Add lib file name.
The two methods are different, it is said that the first method is added only to the project is valid, the second method is added after the entire vs within the project is valid
Python extensions for C + + articles