Boost logo

Boost Users :

Subject: [Boost-users] regex __sync_fetch_and_add_4 issue when compiling to 32 bit Linux
From: Ákos Maróy (akos_at_[hidden])
Date: 2011-01-20 10:20:57


Hi,

I seem to have a problem when trying to link C++ code that refers to the
boost regex library, when this is done so that it is compiled on a 64
bit Linux system, but for a 32 bit target. I get the following error:

libboost_regex.so: undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status

I wonder what needs to be done to fix this.

steps to reproduce:

- compile boost for 32 bit, by:

./bjam architecture=x86 address-model=32 --prefix=/path/to/boost install

- try to compile & link a very simple sample code (see the end of the mail)

g++ -m32 -L//path/to/boost/lib -I/path/to/boost/include -lboost_regex -o
hello hello.cxx
/path/to/boost/lib/libboost_regex.so: undefined reference to
`__sync_fetch_and_add_4'
collect2: ld returned 1 exit status

when compiling the same code for 64 bit, it compiles fine.

seeing this thread: http://lists.boost.org/Archives/boost/2008/04/135586.php

I also tried the following:

g++ -m32 -DBOOST_SP_USE_PTHREADS -L//path/to/boost/lib
-I/path/to/boost/include -lboost_regex -o hello hello.cxx

g++ -m32 -DBOOST_SP_DISABLE_THREADS -L//path/to/boost/lib
-I/path/to/boost/include -lboost_regex -o hello hello.cxx

but I got the same results :(

any help would be appreciated.

Akos

details:
platfrom: Ubuntu 10.10 64 bit
compiler: g++ 4.4.4
boost: 1.45.0

the sample code I used is very minimalistic:

#include <boost/regex.hpp>

int main(void) {
    boost::regex LF("\\\\n"), CR("\\\\r"), TAB("\\\\t");

    return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net