Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing ___emutls_get_address with gcc-4.7 and openMP

I am trying to compile a program using a self-compiled GCC-4.7.1 on Mac OS 10.8.2. The program uses openMP and the compilation succeeds; however, when I try to run the program, the dynamic linker complains with

dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address
  Referenced from: /usr/local/gcc-4.7.1/lib/libgomp.1.dylib
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___emutls_get_address
  Referenced from: /usr/local/gcc-4.7.1/lib/libgomp.1.dylib
  Expected in: /usr/lib/libSystem.B.dylib

This issue is constantly present in any program compiled with -fopenmp, including the MWE

#include <stdio.h>

int main() {
  #pragma omp parallel
  printf("Hallo!\n");
  return 0;
}

Note that the solution suggested in What is the "___emutls_get_address" symbol?, namely adding -lgcc_eh in the linking phase, does not work (I still get the same dyld error message).

like image 571
Marco Lombardi Avatar asked Nov 16 '12 10:11

Marco Lombardi


2 Answers

I had exactly the same problem. In my case it was caused by linking against a library (I don't remember which one) of an older version of gcc installed by XCode, which was in /usr/lib. When I corrected it to link against the newer gcc library of the version I used for compiling (in /usr/local) this error was fixed.

So just check your built executable and all the libraries it is linked with using

otool -L EXECUTABLE_OR_DYLIB

And if you find anything linked with a library of an older gcc, fix that.

like image 116
Michal Fapso Avatar answered Oct 26 '22 02:10

Michal Fapso


I had exactly the same problem too. And I am new to openMP, and my skill is not that good to use the solution offered by Michal Fapso. I solve this problem by using

brew link --overwrite gcc

and the problem is solved!

Maybe you can try to reinstall gcc to your Mac.

like image 9
FL1NT Avatar answered Oct 26 '22 01:10

FL1NT