Boost logo

Boost Users :

Subject: Re: [Boost-users] libboost_date_time: undefined reference to __sync_fetch_and_add_4
From: tom fogal (tfogal_at_[hidden])
Date: 2009-04-03 15:16:27


Carsten Raas <carsten.raas_at_[hidden]> writes:
> -----------------------------------------------------------------
> Shared linking:
> # icpc -I /opt/boost/1.38/intel/include conftest.cpp
> -L /opt/boost/1.38/intel/lib -lboost_date_time
>
> /opt/boost/1.38/intel/lib/libboost_date_time.so:
> undefined reference to `__sync_fetch_and_add_4'
> -----------------------------------------------------------------
> Shared linking with gcc:
>
> # g++ -I /opt/boost/1.38/intel/include conftest.cpp \
> -L /opt/boost/1.38/intel/lib -lboost_date_time
>
> /opt/boost/1.38/intel/lib/libboost_date_time.so:
> undefined reference to `__sync_fetch_and_add_4'
> collect2: ld returned 1 exit status
> -----------------------------------------------------------------

This is an internal function for gcc's atomics extensions.

  http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Atomic-Builtins.html

Can you try adding -lgcc (IIRC; maybe lgcc_s?) to your link line?

Looks like the more global problem is that boost_date_time is using
this symbol, but was not linked against it at build time. It's a bit
strange that your compiler isn't adding this implicitly though...

Cheers,

-tom


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