Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

linker issue, thread local from gcc

Azua_Garcia__Giovann
417 Views
Hello,

I get a linker issue with the Intel Compiler version beta 13 but only while compiling in the Mac OS X platform (in Linux works fine). Basically I have my project that uses and links to PAPI (performance counters library) and PAPI is built using a recent version of GNU compiler (I have exact same setup in Linux).

The linker error is the following and it shows that can't find the GNU's compiler thread local support I think.

Linking CXX executable benchmark
Undefined symbols for architecture x86_64:
  "___emutls_get_address", referenced from:
      _PAPI_register_thread in libpapi.a(papi.o)
      _PAPI_unregister_thread in libpapi.a(papi.o)
      _PAPI_get_thr_specific in libpapi.a(papi.o)
      _PAPI_set_thr_specific in libpapi.a(papi.o)
      _PAPI_create_eventset in libpapi.a(papi.o)
      _PAPI_set_opt in libpapi.a(papi.o)
      _PAPI_shutdown in libpapi.a(papi.o)
      ...
ld: symbol(s) not found for architecture x86_64
make[2]: *** [benchmark] Error 1
make[1]: *** [CMakeFiles/benchmark.dir/all] Error 2
make: *** [all] Error 2

This I can fix by changing the Intel compiler linker options to link to the gcc library gcc_eh that contains the symbol (see below):

/opt/local/bin/cmake -E cmake_link_script CMakeFiles/benchmark.dir/link.txt --verbose=1
/opt/intel/composer_xe_2013.0.060/bin/intel64/icpc    -fasm-blocks -pthread -Wall -Wcheck -g -restrict -O0 -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/benchmark.dir/test/benchmark.cc.o  -o benchmark  libsubmodularity.a libqr_updates.a /opt/local/lib/libboost_filesystem-mt.a /opt/local/lib/libboost_system-mt.a /opt/local/lib/libboost_program_options-mt.a /opt/local/lib/libboost_chrono-mt.a /opt/intel/composer_xe_2013.0.060/mkl/lib/libmkl_rt.dylib /opt/intel/composer_xe_2013.0.060/compiler/lib/libiomp5.dylib /opt/intel/composer_xe_2013.0.060/compiler/lib/libimf.dylib /usr/local/lib/libpapi.a -lgcc_eh /opt/intel/composer_xe_2013.0.060/compiler/lib/libifport.a /opt/intel/composer_xe_2013.0.060/compiler/lib/libifcore.a -lpthread

How can I fix this properly without the workaround of linking to gcc? is there an option? and how come this doesn't happen in Linux given that I have the same versions of all libraries and compilers?

Many TIA,
Best regards,
Giovanni
0 Kudos
0 Replies
Reply