I'm trying to get the boost-python extension module tutorial working on a modern C++14 compiler in Windows 10. I've downloaded the latest versions of boost 1.57 and python 3.5a source using vc-14 (VS 2015 CTP 5).
I compiled python from source using VS 2015 CTP 5 and these instructions: 1.1.3.3. Windows.
I've run the command
.\bootstrap.bat && .\b2 stage toolset=msvc --with-python
from the boost project folder c:\boost
This is the user-config.jam file in my home directory:
using msvc : 14.0 : C:\\Program\ Files\ (x86)\\Microsoft\ Visual\ Studio\ 14.0\\VC\\bin\\cl.exe ;
using python
: 3.5 # Version
: C:\\python35a3\\PCBuild\\win32\\python.exe # Python Path
: C:\\python35a3\\include # include path
: C:\\python35a3\\libs # lib path
: <define>BOOST_ALL_NO_LIB=1
;
Running bjam in the tutorial directory results in an incompatibility when creating the pdb file:
c:\boost\libs\python\example\tutorial>bjam --debug-configuration
notice: found boost-build.jam at C:/boost/libs/python/example/tutorial/boost-build.jam
notice: loading Boost.Build from C:/boost/tools/build/src
....
notice: Loading user-config configuration file 'user-config.jam' from 'C:/Users/marcel'.
notice: [msvc-cfg] msvc-14.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe'
notice: [msvc-cfg] msvc-12.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe'
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' for msvc, condition <toolset>msvc-14.0
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>/<address-model>', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>/<address-model>32', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>x86/<address-model>', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>x86/<address-model>32', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [python-cfg] Configuring python...
notice: [python-cfg] user-specified version: "3.5"
notice: [python-cfg] user-specified cmd-or-prefix: "C:\python35a3\PCBuild\amd64\python_d.exe"
notice: [python-cfg] user-specified includes: "C:\python35a3\include"
notice: [python-cfg] user-specified libraries: "C:\python35a3\libs"
notice: [python-cfg] user-specified condition: "<define>BOOST_ALL_NO_LIB=1"
notice: [python-cfg] Checking interpreter command "C:\python35a3\PCBuild\amd64\python_d.exe"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python35a3\PCbuild\amd64\python_d.exe" 2>&1'
notice: [python-cfg] running command 'C:\python35a3\PCBuild\amd64\python_d.exe -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%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: "C:\python35a3\PCBuild\amd64\python_d.exe"
notice: [python-cfg] include path: "C:\python35a3\include"
notice: [python-cfg] library path: "C:\python35a3\libs"
notice: [python-cfg] DLL search path: "C:\python35a3"
notice: Searching '../../../..' for project-config configuration file 'project-config.jam'.
notice: Loading project-config configuration file 'project-config.jam' from '../../../..'.
....
...patience...
...patience...
...found 1893 targets...
...updating 6 targets...
msvc.link.dll bin\msvc-14.0\debug\threading-multi\hello_ext.dll
Creating library bin\msvc-14.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-14.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-14.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
....
...removing bin\hello.test\msvc-14.0\debug\threading-multi\hello.py
...skipped <pbin\hello.test\msvc-14.0\debug\threading-multi>hello for lack of <pbin\hello.test\msvc-14.0\debug\threading-multi>hello.py...
...failed updating 3 targets...
...skipped 3 targets...
The command producing the error output is:
call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-14.0\debug\threading-multi\hello_ext.dll" /IMPLIB:"bin\msvc-14.0\debug\threading-multi\hello_ext.pdb" /LIBPATH:"C:\python35a3\libs" @"bin\msvc-14.0\debug\threading-multi\hello_ext.dll.rsp"
Creating library bin\msvc-14.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-14.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-14.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
The link command seems to be consistent with the way python and boost are compiled (32 bit on the same compiler version).
Is there an way to diagnose where this error originated?
UPDATE: Compiling with VC9 (VS2010) and a prebuilt python 3.4 installation. I still get the same error:
link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-10.0\debug\threading-multi\hello_ext.pyd" /IMPLIB:"bin\msvc-10.0\debug\threading-multi\hello_ext.pdb" /LIBPATH:"C:\python34\libs" @"bin\msvc-10.0\debug\threading-multi\hello_ext.pyd.rsp"
Creating library bin\msvc-10.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-10.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-10.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
Running the python interpreter to confirm the correct compiler version:
c:\Python34\python.exe
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Apparently this error has nothing to do with the "bleeding edge-ness" of the environment the build is running on. Rather its a direct result of a boost-build configuration issue.
UPDATE 2: Trying the same test with pre-built Python 2.7 and VS 2008 results in the same error.
UPDATE 3 SOLVED This builds correctly on boost v1.55 when the following steps are taken:
- Download and build python 3.5 a3 and build boost 1.55 with VC14 by modifying the user-config.jam file in the home directory and running "bjam stage --use-python"
- Move the resultant files in stage\lib from libboost* to boost* run bjam from the tutorial directory
- Change the errant link command by adding the following LIBPATH switch: /LIBPATH:c:\boost_1_55_0\stage\lib
The problem of linking to python 3.5 alpha3 with VC14 is isolated to boost v1.57 builds.
The problem seems to have been introduced with 1.56. I've managed to get Boost.Build working again by editing the file:
D:\boost\boost_1_59_0\tools\build\src\tools\msvc.jam
I made two changes:
Change this (lines #1351-1355):
generators.register [ new msvc-linking-generator msvc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>msvc <suppress-import-lib>false ] ; generators.register [ new msvc-linking-generator msvc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB : <toolset>msvc <suppress-import-lib>true ] ;
to:
generators.register [ new msvc-linking-generator msvc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>msvc ] ;
Remove this line (#1472):
toolset.flags msvc.link.dll LINKFLAGS <suppress-import-lib>true : /NOENTRY ;
I've tested this on Win7 with VS2012 and Python 2.7.
Yes, I think Boost.Build 1.59 (and possibly 1.57 and 1.58) is broken on Windows. I gave up using Boost.Build and built it myself.
来源:https://stackoverflow.com/questions/29450634/compile-boost-python-tutorial-with-vs-2015-ctp-5-and-python-3-5a-on-windows-10-t