Boost logo

Boost Users :

Subject: [Boost-users] libboost_date_time: undefined reference to __sync_fetch_and_add_4
From: Carsten Raas (carsten.raas_at_[hidden])
Date: 2009-04-03 13:20:00


Hello!

I built a (complete) Boost 1.38 library with the Intel compilers
10.1.021, 11.0.073, and 11.0.081 for an EM64T (x86_64) Linux
architecture. But I end up with the same problem for all builds: the
shared version of libboost_date_time cannot be linked to this simple
demo program:

# cat conftest.cpp
-----------------------------------------------------------------
#include <boost/date_time/date_generators.hpp>
int main ()
{
  const char *ptr = boost::date_time::nth_as_str(0); return 0;
}
-----------------------------------------------------------------
# icpc -V
Intel(R) C++ Intel(R) 64 Compiler Professional
for applications running on Intel(R) 64, Version 11.0
Build 20090131 Package ID: l_cproc_p_11.0.081
-----------------------------------------------------------------
Static linking:
# icpc -I /opt/boost/1.38/intel/include conftest.cpp \
          /opt/boost/1.38/intel/lib/libboost_date_time.a
=> Works.
-----------------------------------------------------------------
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
-----------------------------------------------------------------
Shared linking with gcc to libraries compiled with gcc itself:

# g++ -I /opt/boost/1.38/gcc/include conftest.cpp \
      -L /opt/boost/1.38/gcc/lib -lboost_date_time

=> Works.
-----------------------------------------------------------------

I have been googling around for a while, but all I found was related to
GCC sync primitives (e.g. sync_lock_test_and_set, sync_fetch_and_add)
and different architectures (armel, sparc, etc.). I also tried the
workaround with
        #define BOOST_SP_USE_PTHREADS
in boost/config/user.hpp, without success.

I also checked 1.37 and today's SVN version, but they show the same
problems.
Any hints what I should look at next?

Best regards,
-Carsten


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