[C++-sig] How to compile Boost.Python for 32bit on 64bit Linux

Philipp Münzel mail at philippmuenzel.de
Tue Oct 5 15:41:02 CEST 2010

Hi everyone,

I'm trying to build a Boost.Python 32bit static library on a 64bit Linux
(Suse 11.3).

Of course, I have the respective python-devel and python32 packages for
my platform installed.

I build my minimal work environment of boost-thread, -system and -python
with this command:

sudo ./bjam install -q --layout=system --with-system --with-thread
--with-python toolset=gcc variant=release link=static threading=multi
runtime-link=static address-model=32

As long as I don't include the --with-python option, I get the expected
result:  32bit static libraries.

But with --with-python, I get the following error:

In file included from /usr/include/python2.6/Python.h:58:0,
                 from ./boost/python/detail/wrap_python.hpp:142,
                 from ./boost/python/detail/prefix.hpp:13,
                 from ./boost/python/numeric.hpp:8,
                 from libs/python/src/numeric.cpp:6:
/usr/include/python2.6/pyport.h:685:2: error: #error "LONG_BIT
definition appears wrong for platform (bad gcc/glibc config?)."

    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall
-DBOOST_PYTHON_STATIC_LIB -DNDEBUG  -I"." -I"/usr/include/python2.6" -c

...failed gcc.compile.c++
...failed updating 1 target...

Apparently, my python headers in /usr/include/python2.6 make the
assumption that on a 64bit platform one wants to build always 64bit

How can I compile boost.python for 32bit without having to edit the
respective header file and hard-coding the word size, which would render
it unusable for a native build?

Any help is appreciated.


More information about the Cplusplus-sig mailing list