I'm trying to follow this tutorial on embedding Python into a C++ application, and am hitting a roadblock right from the beginning. Let me take you through it...
- I extract the boost library to C:\codelibraries\c++\boost_1_55_0
I creat a new project in VC+++ and create a 'test1.cpp' file in it with the following code:
#include <boost/python.hpp> int main(int, char**) { Py_Initialize(); Py_Finalize(); return 0; }
- I then place the following directories in my VC++ Directories > Include Directories:
- C:\codelibraries\c++\boost_1_55_0
- C:\codelibraries\c++\boost_1_55_0\boost\python
- C:\Python27\include
- In my VC++ Directories > Library Directories:
- C:\codelibraries\c++\boost_1_55_0
- C:\codelibraries\c++\boost_1_55_0\libs
- C:\Python27\libs
- And in my VC++ Directories > Source Directories:
- C:\Python27\include
- C:\codelibraries\c++\boost_1_55_0
After adding these and running it, I am given error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_55.lib'.
Okay, turns out that I need to actually install the boost library. Fine. I do so. It creates the new folder '..\boost_1_55_0\stage\lib.' Inside it, there is the library file called libboost_python-vc100-mt-gd-1_55.lib and another one that's very similar but excludes the 'gd' portion.
Under 'Linker' > 'General' > 'Additional Library Directories', I added C:\codelibraries\c++\boost_1_55_0\stage\lib. I run it again. still it gives the same linker error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_55.lib'. I go to the 'stage\lib' folder and see that there is no boost_python-vc100-mt-gd-1_55.lib, only *lib*boost_python-vc100-mt-gd-1_55.lib.
I rename libboost_python-vc100-mt-gd-1_55.lib to boost_python-vc100-mt-gd-1_55.lib and rerun the build.
It succeeds, but gives me other linker errors:
error LNK1120: 3 unresolved externals
error LNK2001: unresolved external symbol __imp___Py_NoneStruct
error LNK2019: unresolved external symbol __imp__Py_Finalize referenced in function _main
error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main
And now I'm stuck and have come here. Are the few lines of code I have written incorrect? Does it have anything to do with my using a 64-bit machine? Are my includes incorrect? Please help if you can. Any information is greatly appreciated, thank you.
<boost/python.hpp>
and trace backwards to where<boost/config/auto_link.hpp>
is being included, and see if you can figure out why auto linking is getting the name wrong. – Praetorian