Visual Studio 2008 中 Boost.Python 的链接器错误
A linker error of Boost.Python in Visual Studio 2008
我的英语很差,所以如果你试着理解我的问题,我将不胜感激.
我安装了Python3.3,Boost 1.50.0和Visual Studio 2008,它们都可以正常工作><。现在我想通过使用 Boost Python 库在 C++ 中嵌入 python 2.7.6,所以我下载了可移植的 Python 2.7.6.1(来自 portablepython.com/).
我下载了Boost lib。1.50.0 再次将它们提取到另一个路径中,按照构建教程编译它们.
一切似乎都很好,但是当我尝试编译代码时,我遇到了链接器错误。
Error LNK1104 cannot open file 'python32.lib'
我不知道为什么它不是'python27.lib'
我很困惑,因为我从未安装 Python3.2,并且我修改了 user-config.jam 以确保所有路径都已重定向到我的可移植 Python(2.7) 文件夹,并且新的 Boost 库已成功构建,没有错误.
几周来,我一直在尝试解决问题,使用多种方法,但仍然不起作用
我所做的所有事情都是:
下载 Boost C++ 库(www.boost.org/users/history/version_1_50_0.html boost_1_50_0.7z)
将它们解压缩到我的提升根路径(D:\Proj\第三方库\boost_1_50_0)
下载可移植的Python 2.7.6.1(从 portablepython.com/wiki/PortablePython2.7.6.1/)
将它们提取到 D:\Py27Test
修改
user-config.jam
,添加以下文本并将其保存到 D:\Proj\第三方库\boost_1_50_0\
using python : 2.7 : "D:Py27TestApp" : "D:Py27TestAppinclude" : "D:Py27TestApplibs" : ;
执行 Visual Studio 命令提示符 (x86)
-
cd /D D:ProjThirdPartyLibboost_1_50_0
-
bootstrap
bjam --toolset=msvc-9.0 --python=2.7 --user-config=D:ProjThirdPartyLibboost_1_50_0user-config.jam --debug-configuration
调试信息为:
notice: [python-cfg] Configuring python...
notice: [python-cfg] user-specified version: "2.7"
notice: [python-cfg] Checking interpreter command "python"...
notice: [python-cfg] running command 'DIR /-C /A:S "D:Py27TestApppython.exe" 2>&1'
notice: [python-cfg] running command '"python" -c "from sys import *; print('version=%d.%dnplatform=%snprefix=%snexec_prefix=%snexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg] interpreter command: "python"
notice: [python-cfg] include path: "D:Py27TestAppinclude"
notice: [python-cfg] library path: "D:Py27TestApplibs"
notice: [python-cfg] DLL search path: "D:Py27TestApp"
-
执行 Visual Studio 2008
- 将 D:\Proj\第三方库\boost_1_50_0添加到编译器包含路径
- 将 D:\Proj\第三方库\boost_1_50_0\stage\lib 添加到链接器库路径
创建测试代码:
#define BOOST_PYTHON_STATIC_LIB #include <boost/python.hpp> #include <iostream> int main(int argc, char** argv) { return 0; }
- 遵守代码,我会得到一个链接器错误(错误LNK1104无法打开文件"python32.lib")
我错过了什么吗?
或者有人有任何想法来解决这个问题吗?
提前致谢
最后,我解决了这个问题。
- 将 D:\Py27Test\App\include 添加到编译器包含路径
- 将 D:\Py27Test\App\libs 添加到链接器库路径
似乎如果我不包括 Python.h,它将链接到默认库文件。因此,在我添加这些路径后,它现在可以工作了。
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误