我正在使用Python 2.7和MinGW 4.7在Windows8上构建spotify / annoy库, 首先,我下载boost 1.5.7并使用以下命令成功构建Boost.Python:
b2 toolset=gcc --with-python
这个生成的serval库:
2015/03/18 10:27 707,484 libboost_python-mgw47-1_57.a
2015/03/18 10:25 10,851,410 libboost_python-mgw47-d-1_57.a
2015/03/18 10:23 707,484 libboost_python-mgw47-mt-1_57.a
2015/03/18 10:22 10,851,410 libboost_python-mgw47-mt-d-1_57.a
2015/03/18 10:30 707,484 libboost_python-mgw47-mt-s-1_57.a
2015/03/18 10:28 10,851,410 libboost_python-mgw47-mt-sd-1_57.a
2015/03/18 10:33 707,484 libboost_python-mgw47-s-1_57.a
2015/03/18 10:31 10,851,410 libboost_python-mgw47-sd-1_57.a
然后,我用
建立了spotify / annoypython setup.py build --compiler=mingw32
它成功生成了annoymodule.o
文件,但链接过程出错,如下所示:
E:\develop\Anaconda\MinGW\bin\g++.exe -DMS_WIN64 -shared -s build\temp.win-amd64
-2.7\Release\src\annoymodule.o build\temp.win-amd64-2.7\Release\src\annoylib.def
-LE:\develop\Anaconda\libs -LE:\develop\Anaconda\PCbuild\amd64 -lboost_python -
lpython27 -lmsvcr90 -o build\lib.win-amd64-2.7\annoy\annoylib.pyd
build\temp.win-amd64-2.7\Release\src\annoymodule.o:annoymodule.cc:(.text+0x366):
undefined reference to `__imp__ZN5boost6python6detail11init_moduleEPKcPFvvE'
build\temp.win-amd64-2.7\Release\src\annoymodule.o:annoymodule.cc:(.text+0x443):
undefined reference to `__imp__ZN5boost6python7objects10class_baseC2EPKcyPKNS0_
9type_infoES4_'
build\temp.win-amd64-2.7\Release\src\annoymodule.o:annoymodule.cc:(.text+0x46d):
undefined reference to `__imp__ZN5boost6python9converter8registry6insertEPFPvP7
_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoEPFPK11_typeo
bjectvE'
我已经尝试过Boost.Python包生成的所有库文件,但它根本不起作用。 有人可以帮帮我吗?