[C++-sig] EXTERNAL: Building Boost Python problem
Davidson, Josh
josh.davidson at lmco.com
Wed Dec 21 17:53:17 CET 2011
I'm attaching my notes below. I will point out that while the directions reference 1.48, I've actually had problems with 1.48 and MinGW-W64. Specifically, I'm having problems with bjam building all libraries at once. Building individually appears to work, but I haven't bothered trying to build each one on its own yet. I've inquired on boost-build, but haven't heard anything back. Personally, I would recommend 1.47. If you'd like the def file referenced in the instructions, shoot me a personal email and I'll forward it to you. Keep in mind that you *cannot* use a 32-bit def file if you are using 64-bit Python. I will also forewarn you there are other issues with x64 Python and MinGW-W64 if you plan on building extensions. Take a look here: http://bugs.python.org/issue4709
---Building Boost for MinGW-----
h1. Building Boost
Building Boost for MinGw is the opposite of fun. Here are some notes to get you through the misery.
h2. x64 Windows
*Directories*
* C:\TEMP\boost_1_48_0 - Where Boost source code was extracted
* c:\mingw64-i686-20110207 - 64-bit MinGw
* C:\Python26 - 64-bit Python installation (2.6.6)
* C:\TEMP\boost_build - Directory for storing build output
*Steps*
# Enter C:\TEMP\boost_1_48_0\tools\build\v2\engine
# C:\TEMP\boost_1_48_0\tools\build\v2\engine>build.bat mingw --toolset-root=c:\mingw64-i686-20110207
# Copy bin.<arch>/* to <mingw_root>/bin
# Change into C:\TEMP\boost_1_48_0
# C:\TEMP\boost_1_48_0>bootstrap.bat mingw --toolset-root=c:\mingw64-i686-20110207 --with-python-root=C:\Python26
# Make a temporary boost build directory, C:\TEMP\boost_build
# Work through the following steps to workaround a bug that has been around for years, but seemingly will never get fixed:
<pre>1. Open tools/build/v2/tools/python.jam
2. There, locate the following code:
if [ version.check-jam-version 3 1 17 ] || ( [ os.name ] != NT )
{
# Prior to version 3.1.17 Boost Jam's SHELL command did not support
# quoted commands correctly on Windows. This means that on that
# platform we do not support using a Python command interpreter
# executable whose path contains a space character.
python-cmd = \"$(python-cmd)\" ;
}
3. Remove that code block completely. </pre>
# Grab attachment:python26.def
# Copy c:\windows\System32\python26.dll to the same location as attachment:python26.def
# Execute: @dlltool --dllname python26.dll --def python26.def --output-lib libpython26.a@
# Copy libpython26.a to C:\Python26\libs
# pre>
bjam.exe --toolset=gcc --build-type=complete --build-dir=C:\TEMP\boost_build\build --stagedir=C:\TEMP\boost_build\stage -- address-model=64 define=BOOST_USE_WINDOWS_H threadapi=win32 target-os=windows stage
</pre>
# Copy all files under C:\temp\boost_build\stage\lib to c:\mingw64-i686-20110207\x86_64-w64-mingw32\lib64
# Copy C:\TEMP\boost_1_48_0\boost to c:\mingw64-i686-20110207\x86_64-w64-mingw32\inlcude
-----Original Message-----
From: cplusplus-sig-bounces+josh.davidson=lmco.com at python.org [mailto:cplusplus-sig-bounces+josh.davidson=lmco.com at python.org] On Behalf Of hbd666
Sent: Wednesday, December 21, 2011 2:24 AM
To: cplusplus-sig at python.org
Subject: EXTERNAL: [C++-sig] Building Boost Python problem
Hi I hope someone can help me out...
The object is to build boost python (boost-1.4.8, python 2.7 32bit, windows 7 64bit, mingw).
I've been trying to fix this for a good 8 hours but can't figure it out.
bjam --with-python --build-type=complete --toolset=gcc stage
Looking at the resulting output below, I see the problem is probably that bjam can't find python27.lib. I just don't see how that is possible because it finds python.exe in C:\Python27 and indeed python27.lib exists in the C:\Python27\libs directory.
Resulting output.....
Component configuration:
- chrono : not building
- date_time : not building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : not building
- math : not building
- mpi : not building
- program_options : not building
- python : building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : not building
- test : not building
- thread : not building
- timer : not building
- wave : not building
...patience...
...patience...
...found 1932 targets...
...updating 16 targets...
gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll.a
Creating library file:
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll.abin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\module.o:module.cpp:(.text+0x165):
undefined reference to `_imp__Py_InitModule4 '
collect2: ld returned 1 exit status
"g++" -L"C:\Python27\libs" -Wl,-R -Wl,"C:\Python27" -Wl,-R -Wl,"C:\Python27\libs"
"-Wl,--out-implib,bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll.a"
-o
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll"
-shared -Wl,--start-group
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\numeric.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\list.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\long.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\dict.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\tuple.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\str.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\slice.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\converter\from_python.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\converter\registry.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\converter\type_id.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\enum.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\class.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\function.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\inheritance.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\life_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\pickle_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\errors.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\module.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\converter\builtin_converters.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\converter\arg_to_python_base.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\stl_iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object_protocol.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object_operators.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\wrapper.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\import.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\exec.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\object\function_doc_signature.o"
-Wl,-Bstatic -Wl,-Bdynamic -lpython27 -Wl,--end-group -mthreads
...failed gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll.a
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll...
...removing
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi\libboost_python-mgw46-mt-1_48.dll.a
...skipped <pstage\lib>libboost_python-mgw46-mt-1_48.dll.a for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi>libboost_python-mgw46-mt-1_48.dll.a...
...skipped <pstage\lib>libboost_python-mgw46-mt-1_48.dll for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\release\threading-multi>libboost_python-mgw46-mt-1_48.dll...
gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll.a
Creating library file:
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll.abin.v2\libs\python\build\gcc-mingw-4.6.1\debug\module.o:
In function `ZN5boost6python6detail11init_moduleEPKcPFvvE':
D:\boost_1_48_0\libs\python\example\quickstart/../../../../libs/python/src/module.cpp:59:
undefined reference to `_imp__Py_InitModule4 '
collect2: ld returned 1 exit status
"g++" -L"C:\Python27\libs" -Wl,-R -Wl,"C:\Python27" -Wl,-R -Wl,"C:\Python27\libs"
"-Wl,--out-implib,bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll.a"
-o
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll"
-shared -Wl,--start-group
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\numeric.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\list.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\long.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\dict.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\tuple.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\str.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\slice.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\converter\from_python.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\converter\registry.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\converter\type_id.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\enum.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\class.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\function.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\inheritance.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\life_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\pickle_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\errors.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\module.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\converter\builtin_converters.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\converter\arg_to_python_base.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\stl_iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object_protocol.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object_operators.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\wrapper.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\import.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\exec.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\object\function_doc_signature.o"
-Wl,-Bstatic -Wl,-Bdynamic -lpython27 -Wl,--end-group -g
...failed gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll.a
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll...
...removing
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\libboost_python-mgw46-d-1_48.dll.a
...skipped <pstage\lib>libboost_python-mgw46-d-1_48.dll.a for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\debug>libboost_python-mgw46-d-1_48.dll.a...
...skipped <pstage\lib>libboost_python-mgw46-d-1_48.dll for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\debug>libboost_python-mgw46-d-1_48.dll...
gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll.a
Creating library file:
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll.abin.v2\libs\python\build\gcc-mingw-4.6.1\release\module.o:module.cpp:(.text+0x165):
undefined reference to `_imp__Py_InitModule4 '
collect2: ld returned 1 exit status
"g++" -L"C:\Python27\libs" -Wl,-R -Wl,"C:\Python27" -Wl,-R -Wl,"C:\Python27\libs"
"-Wl,--out-implib,bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll.a"
-o
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll"
-shared -Wl,--start-group
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\numeric.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\list.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\long.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\dict.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\tuple.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\str.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\slice.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\converter\from_python.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\converter\registry.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\converter\type_id.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\enum.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\class.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\function.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\inheritance.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\life_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\pickle_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\errors.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\module.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\converter\builtin_converters.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\converter\arg_to_python_base.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\stl_iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object_protocol.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object_operators.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\wrapper.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\import.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\exec.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\release\object\function_doc_signature.o"
-Wl,-Bstatic -Wl,-Bdynamic -lpython27 -Wl,--end-group
...failed gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll.a
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll...
...removing
bin.v2\libs\python\build\gcc-mingw-4.6.1\release\libboost_python-mgw46-1_48.dll.a
...skipped <pstage\lib>libboost_python-mgw46-1_48.dll.a for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\release>libboost_python-mgw46-1_48.dll.a...
...skipped <pstage\lib>libboost_python-mgw46-1_48.dll for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\release>libboost_python-mgw46-1_48.dll...
gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll.a
Creating library file:
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll.abin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\module.o:
In function `ZN5boost6python6detail11init_moduleEPKcPFvvE':
D:\boost_1_48_0/libs/python/src/module.cpp:59: undefined reference to
`_imp__Py_InitModule4
'
collect2: ld returned 1 exit status
"g++" -L"C:\Python27\libs" -Wl,-R -Wl,"C:\Python27" -Wl,-R -Wl,"C:\Python27\libs"
"-Wl,--out-implib,bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll.a"
-o
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll"
-shared -Wl,--start-group
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\numeric.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\list.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\long.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\dict.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\tuple.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\str.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\slice.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\converter\from_python.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\converter\registry.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\converter\type_id.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\enum.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\class.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\function.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\inheritance.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\life_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\pickle_support.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\errors.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\module.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\converter\builtin_converters.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\converter\arg_to_python_base.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\stl_iterator.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object_protocol.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object_operators.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\wrapper.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\import.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\exec.o"
"bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\object\function_doc_signature.o"
-Wl,-Bstatic -Wl,-Bdynamic -lpython27 -Wl,--end-group -g -mthreads
...failed gcc.link.dll
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll.a
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll...
...removing
bin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi\libboost_python-mgw46-mt-d-1_48.dll.a
...skipped <pstage\lib>libboost_python-mgw46-mt-d-1_48.dll.a for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi>libboost_python-mgw46-mt-d-1_48.dll.a...
...skipped <pstage\lib>libboost_python-mgw46-mt-d-1_48.dll for lack of <pbin.v2\libs\python\build\gcc-mingw-4.6.1\debug\threading-multi>libboost_python-mgw46-mt-d-1_48.dll...
...failed updating 8 targets...
...skipped 8 targets...
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
More information about the Cplusplus-sig
mailing list