I recently built 32-bit Boost 1.48 on a 64-bit machine using gcc 4.5, using these instructions:
./bootstrap.sh --prefix=$INSTALL_PREFIX --exec-prefix=$INSTALL_PREFIX --with-libraries=system,filesystem,python --with-python=python2
./b2 address-model=32 architecture=x86 install
Compilation seems fine and libraries are correctly placed into the installation folder. But when I try to link libboost_filesystem.so to one of my programs I get the following error:
/gpfs/wizard/flight/analysis/mori/GGSINSTALL/install/lib/libboost_filesystem.so: undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
I manage my code using CMake; these are the flags I use to configure the 32-bit build:
-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
I don't know if I'm doing something wrong in Boost configuration or in my software configuration via CMake flags, but I suspect Boost. I found some discussions on this topic (eg. undefined reference to sync_fetch_and_add_4) but they almost always refer to other architectures like arm or report solutions which I don't know how to implement in boost build (eg. passing a -march=i486 to gcc, how can this be done with bjam?). Can anybody give me some hints, please? Thanks.