【发布时间】:2017-07-24 15:36:34
【问题描述】:
我一直在尝试达到使用 Boost-Python 的 0 级(在安装了 VS2015 和 Python 3.6 的 Windows 10 上),即构建教程,基本上是最后整整 3 天。 我首先尝试通过官方教程: - http://www.boost.org/doc/libs/1_64_0/libs/python/doc/html/tutorial/tutorial/hello.html 但它不会工作。在我看来,该示例的设置需要“教程”目录中的“Jamfile”和父目录中的“Jamroot”。
经过调查/搜索,我开始回答:- Can't run bjam to compile boost python tutorial 目前我被困住了
致命错误 C1083:无法打开包含文件:'boost/python/module.hpp':没有这样的文件或目录
我会继续努力,但第一个问题:-
1) 在我看来,我应该能够使用 bjam.exe 构建 boost_1_64_0\libs\python\tutorial 中的以下文件:hello.cpp、hello.py、一些 .lib(如 boost_python3-vc140-mt -gd-1_64.lib 或其他东西),教程目录中合适的Jamfile,bjam.exe 和父目录中合适的Jamroot 和我的HOMEPATH 中的user-config.jam。那正确吗 ?
事实上,经过上周的深思熟虑和尝试,我得到了进一步的提升,得到以下链接器错误:-
LINK:致命错误 LNK1207:“C:\Program Files\boost\boost_1_64_0\libs\python\example\tutorial\hello_ext.pdb”中的 PDB 格式不兼容;删除并重建 调用“C:\Users\DIAMON~1\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd” 空链接 /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"hello_ext.dll" /IMPLIB:"hello_ext.pdb" /LIBPATH:"C:\Users\DiamondExp \AppData\Local\Programs\Python\Python36-32\libs" @"hello_ext.dll.rsp"
如果 %ERRORLEVEL% NEQ 0 退出 %ERRORLEVEL%
...失败 msvc.link.dll hello_ext.dll hello_ext.pdb hello_ext.pdb...
然后我输了——我不得不非常可耻地承认——当我愚蠢地删除我的整个 boost 目录以从“干净状态”开始时,部分工作的 Jamfile/Jamroot。真的很蠢。 无论如何,我真的找不到任何地方可以解决这个致命错误 LNK1207。
我非常渴望进入这个 Boost-Python 的东西,这会让我的生活更轻松。因此,我将非常感谢经验丰富的 Boost-Python 和/或 Boost.Build 用户提供的任何意见,并可能得到以下具体问题的解答:
2) 我应该如何修改我的 'libs\python\example\Jamroot' (特别是在 "" 之后)和 'libs\python\example\tutorial\Jamfile' ? 当前状态转载如下。 Boost.Python 的所谓“默认位置”是什么?
3) 它是抛弃 bjam.exe 并尝试直接使用 VisualStudio 2015 构建的好选择吗? 喜欢那里:Building/including Boost.Python in VS2013
4) 从一些帖子看来,在 Boost 1_55 之后发生了一些事情。有几个人无法让它工作。 Boost-Python 和 msvc14.0 或 Python 3.x 之间是否存在任何已知的兼容性问题? 例如 : Compile boost-python tutorial with VS-2015 CTP 5 and Python 3.5a on Windows 10 TP
5) 我对 32 位/64 位的东西感到困惑。我安装了 64 位操作系统(Windows10)和 Python 32 位。我应该在调用 b2.exe 时将我的“地址模型选项”与什么匹配?这有关系吗?
6) 在这里使用 .dll 而不是 .lib 值得吗?
希望有人能做到这一点......
Jamfile :(默认没有修改)
import python ;
project tutorial
: requirements
<location>.
;
python-extension hello_ext : hello.cpp ;
run-test hello : hello_ext hello.py ;
alias test : hello ;
explicit test ;
果酱:
import python ;
if ! [ python.configured ]
{
ECHO "warning: no Python configured in user-config.jam" ;
ECHO "warning: will use default configuration" ;
using python ;
}
# Adjust the following if Boost.Python isn't installed in a default location
lib boost_python ;
project
: requirements
<include>C:\\Users\\DiamondExp\\Downloads\\boost_1_64_0\\boost_1_64_0\\boost\\python
<library>boost_python
;
rule run-test ( test-name : sources + )
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
}
#build-project quickstart ;
build-project tutorial ;
if [ python.numpy ]
{
build-project numpy ;
}
user-config.jam
# -------------------
# MSVC configuration.
# -------------------
# Configure specific msvc version (searched for in standard locations and PATH).
using msvc : 14.0 : "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe" ;
# ---------------------
# Python configuration.
# ---------------------
# Configure specific Python version.
# using python : 3.6 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;
using python
: 3.6 # Version
: C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe # Python Path
: C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\include # include path
: C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\libs # lib path(s)
: <define>BOOST_ALL_NO_LIB=1
;
【问题讨论】:
-
恕我直言,如果您还没有将 BJam 用于其他用途,请不要打扰它。只需设置少量路径并链接到正确的库,因此请使用您熟悉的任何方法。
-
要添加到 @DanMašek 评论,最近 Boost 指导委员会宣布了将 Boost 构建系统迁移到 CMake 的愿望和意图 - 请参阅 this。除非出于任何原因,否则不要打扰 bjam 的另一个原因。
-
好的。谢谢你的建议。那我直接试试VS吧。希望它能把我带到某个地方。
-
您的第一个“我被卡住了”是由于您的 jamroot 中的路径错误。您需要在您的情况下指定根:“C:\\Users\\DiamondExp\\Downloads\\boost_1_64_0\\boost_1_64_0”
标签: python python-3.x boost boost-python bjam