I'm trying to compile a simple main.cpp
which just includes boost/python.hpp
.
Like the following:
#include <boost/python.hpp>
int main() {
return 0;
}
I'm using MSVC command line tools from my git-bash
shell. I know that cl.exe
need some environment variable that can be found in vcvars32.bat
.
Here is how I'm compiling/linking my main.cpp
:
# Since I'm using git-bash, I can use '-' instead of '/' for options, also
# `clwrap` is a tiny script that runs vcvars32.bat and forward arguments to `cl.exe`
# `python27.lib` and the boost.python lib are automatically autolink
$ clwrap -MD -I/c/Python27/include -I$BOOST_ROOT main.cpp -link -LIBPATH:"C:\\Python27\\libs" -LIBPATH:"C:\\Users\\Charly\\works\\cpp\\boost_1_57_0\\stage\\lib"
When I'm doing this, this ends up with a linking error:
main.obj : error LNK2019: unresolved external symbol __imp___Py_NoneStruct referenced in function "public: __thiscall boost::python::api::object::object(void)" (??0object@api@python@boost@@QAE@XZ)
So, I decide to check my python27.lib
file to see if the missing symbol is here:
$ nm /c/Python27/libs/python27.lib | grep Py_None
NOTHING!!
But, the symbol is in my libpython27.a
:
$ nm /c/Python27/libs/libpython27.a | grep Py_None
00000000 I __imp__Py_NoneStruct
00000000 T _Py_NoneStruct
I did install python
using the .msi
installer (64bits). I built boost.python
with the good address-model=64
. Here is my CLI for building boost.python
:
.\bootstrap.bat
.\b2 --with-python --build-type=complete address-model=64 variant=release link=shared toolset=msvc
Did I miss something? Is the python
installer buggy? (I've found an issue about something similar)...
To be honest, I've tried many things, also I'm not really used to Windows development environment, so maybe I've missed something!
Thanks!