0

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.

Community
  • 1
  • 1
Nicola Mori
  • 777
  • 1
  • 5
  • 19

2 Answers2

1

One solution I found is to remove the architecture=x86 flag in b2 invocation. Another working solution is described here: How do I force a 32 bit build of boost with gcc?

Community
  • 1
  • 1
Nicola Mori
  • 777
  • 1
  • 5
  • 19
0

had the same issue when i compiled boost 1.50.0 on ubuntu 10.4 lts x64

i used the same flags as described....as Nicola Mori suggested skip the architecture=x86 flag and generate the libs. this worked for me

note that however on mac os x lion you DO need to specify architecture and address model to compile in 32bit

Mr Bat Lee
  • 122
  • 5