[英]boost python keeps linking python27 library
Since days I am trying to get started with boost python on windows instead of my raspberry pi and I am facing issues with boost (or some of its dependencies) insisting on linking against python27.lib
instead of python36.lib
(I am using Python 3.6) 由于几天我想开始使用升压Windows上的Python,而不是我的树莓派,我面临着提升(或它的一些依赖)关于对链接坚持问题
python27.lib
代替python36.lib
(我使用Python 3.6 )
On my raspberry pi I was using the bundled python which happened to be 2.X and linked against boost_python. 在我的树莓派上,我正在使用捆绑的python,它刚好是2.X并与boost_python链接。 Now on windows I am linking against boost_python3.
现在在Windows上,我链接到boost_python3。 I checked all my include paths in CMake and they all point to the 3.6 python path.
我在CMake中检查了所有包含路径,它们都指向3.6 python路径。 I even renamed all paths on my system that contain python (one standalone 2.7 and one in cygwin) in a different version (I renamed cygwin folder to
cygwin2
and deleted the standalone python 2.7 folder). 我什至在系统上重命名了包含python(一个独立的2.7和cygwin中的一个)的所有路径的其他版本(我将cygwin文件夹重命名为
cygwin2
并删除了独立的python 2.7文件夹)。 It still wants that library... 它仍然想要那个图书馆...
In my program I have one single #include
related to python and that's a #include <boost/python.hpp>
. 在我的节目,我有一个单一
#include
与蟒蛇,这是一个#include <boost/python.hpp>
I followed that include in visual studio and it leads me to the python.hpp in the boost directory that I have specified in CMake, so that resolution is working. 我遵循了Visual Studio中的include,它将我带到我在CMake中指定的boost目录中的python.hpp,这样分辨率就可以了。 Inside
boost/python.hpp
eventually you get to wrap_python.hpp
which includes the python headers. 在
boost/python.hpp
内部,最终您将进入wrap_python.hpp
,其中包含python标头。 I also followed these in Visual Studio and it leads me to the files in the Python 3.6 folder. 我在Visual Studio中也遵循了这些规则,它引导我进入Python 3.6文件夹中的文件。
Adding a comment to that include (removing it) makes the program compile fine, so I did not accidentally add it in CMake as a library. 在包含(删除)的注释中添加(使之删除)可使程序正常编译,因此我没有意外地将其作为库添加到CMake中。 It has to be some
#pragma comment
somewhere. 在某处必须有一些
#pragma comment
。
So to sum up: 所以总结一下:
#include <Python.h>
in my code #include <Python.h>
boost/python.hpp
once boost/python.hpp
add_definitions(... -DBOOST_ALL_NO_LIB -DBOOST_PYTHON_DEBUG)
add_definitions(... -DBOOST_ALL_NO_LIB -DBOOST_PYTHON_DEBUG)
禁用了自动链接以增强CMake My question(s): 我的问题:
#pragma
so I can track it down (because I am pretty sure it somehow somewhere gets a 2.7 python I am not aware of...) #pragma
所有文件/行,因此我可以对其进行跟踪(因为我很确定它以某种方式会得到一个我不知道的2.7 python ...) I just went through this Boost will check for PY_MAJOR_VERSION
to determine which libs to link with. 我刚刚经历了这个 Boost,它将检查
PY_MAJOR_VERSION
以确定要链接的库。 So in c++ > General > Additional Include Directories
, add your python include path so boost can see that PY_MAJOR_VERSION == 3
. 因此,在
c++ > General > Additional Include Directories
,添加python include路径,以便boost可以看到PY_MAJOR_VERSION == 3
。 If it doesn't it will pull the 2.x libs in by default. 如果不是,它将默认拉入2.x库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.