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

Philipp Münzel mail at philippmuenzel.de
Tue Oct 5 17:33:57 CEST 2010


I also tried python 2.6.6 now, getting the same result.
The core dump yields this stack trace:

Core was generated by `./python -c import sys; print sys.maxint'.
Program terminated with signal 11, Segmentation fault.
#0  pmerge (type=0x0) at Objects/typeobject.c:1462
1462        to_merge_size = PyList_GET_SIZE(to_merge);
(gdb) bt full
#0  pmerge (type=0x0) at Objects/typeobject.c:1462
        i = <value optimized out>
        empty_cnt = <value optimized out>
        remain = <value optimized out>
        ok = <value optimized out>
        j = <value optimized out>
        to_merge_size = <value optimized out>
#1  mro_implementation (type=0x0) at Objects/typeobject.c:1589
        i = <value optimized out>
        n = 0
        ok = -1
        bases = 0x0
        result = 0xf74ff7ec
        to_merge = 0x0
        bases_aslist = <value optimized out>
#2  0x08150400 in ?? ()
No symbol table info available.
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Philipp

On 10/05/2010 05:07 PM, Philipp Münzel wrote:
> Hi Charles,
> 
> thanks for the fast answer!
> So I downloaded python 2.7 source and did:
> 
> OPT=-m32 LDFLAGS=-m32 ./configure --prefix=/opt/pym32
> make
> 
> Unfortunately, the build fails:
> 
> /bin/sh: line 1: 23704 Segmentation fault      CC='gcc -pthread'
> LDSHARED='gcc -pthread -shared' LDFLAGS='-m32' OPT='-DNDEBUG -m32'
> ./python -E ./setup.py build
> make: *** [sharedmods] Error 139
> 
> Any thoughts?
> 
> Philipp
> 
> On 10/05/2010 04:02 PM, Charles Solar wrote:
>> You need to compile boost python with a 32 bit version of python.  The
>> version bjam is finding is 64 bit.  If you have a 32 bit python
>> somewhere you need to tell bjam where to find the right headers.  See
>> this page http://www.boost.org/doc/libs/1_44_0/libs/python/doc/building.html#configuring-boost-build
>>
>> More than likely you are going to have to compile your own 32 bit
>> version of python because the packages for your system are all going
>> to be 64 bit, but it sounds like you may already have a 32 bit version
>> installed.
>>
>> Also fyi, manually editing the python header file will not work.  You
>> may be able to compile but the machine's python will not be able to
>> load the binaries.
>>
>> Charles
>>
>> On Tue, Oct 5, 2010 at 8:41 AM, Philipp Münzel <mail at philippmuenzel.de> wrote:
>>> 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:
>>>
>>> gcc.compile.c++
>>> bin.v2/libs/python/build/gcc-4.5/release/address-model-32/link-static/runtime-link-static/threading-multi/numeric.o
>>> 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
>>> -pthread -m32  -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE
>>> -DBOOST_PYTHON_STATIC_LIB -DNDEBUG  -I"." -I"/usr/include/python2.6" -c
>>> -o
>>> "bin.v2/libs/python/build/gcc-4.5/release/address-model-32/link-static/runtime-link-static/threading-multi/numeric.o"
>>> "libs/python/src/numeric.cpp"
>>>
>>> ...failed gcc.compile.c++
>>> bin.v2/libs/python/build/gcc-4.5/release/address-model-32/link-static/runtime-link-static/threading-multi/numeric.o...
>>> ...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
>>> libraries.
>>>
>>> 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.
>>>
>>> Regards,
>>> Philipp
>>>
>>> _______________________________________________
>>> Cplusplus-sig mailing list
>>> Cplusplus-sig at python.org
>>> http://mail.python.org/mailman/listinfo/cplusplus-sig
>>>
>> _______________________________________________
>> 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