OpenMP + linux - GOMP_4.0 not found

Yurkee picture Yurkee · Aug 18, 2016 · Viewed 10.3k times · Source

I've been trying to compile a program which uses OpenMP on suse with gcc --version 4.9.4

> g++ -std=c++11 -o a.exe -fopenmp ./file.cpp
> ./a.exe

./a.exe: /usr/lib64/libgomp.so.1: version `GOMP_4.0' not found (required by ./a.exe)

I have a file named "/usr/lib64/libgomp.so.1" how may I fix it?

Answer

Harald picture Harald · Aug 18, 2016

Since you have multiple GCC-compiler installations (4.3 and 4.9), it is likely that your problem arises because you compile with GCC 4.9 (which supports OpenMP 4.0) but at runtime the OS loader uses the GCC 4.3 libraries (which does not support OpenMP 4.0).

There are some alternatives to avoid this issue:

  1. Statically compile your binary by using -static at link time.
  2. Make O/S to search the appropriate libraries rather than the old libraries. You can use the command

    find / name -name libgomp.so.1
    

    to list the available libgomp libraries from your system and then add the directory where it is stored into the LD_LIBRARY_PATH environment variable.

  3. Alternatively to 2), you can also tell the linker to generate a binary and letting it to know where to find additional shared libraries in addition to where LD_LIBRARY_PATH points to. You can also use gcc ... -Wl,-rpath -Wl,<dir>/lib (or lib64 rather than lib, if it applies) where <dir> refers to the directory from point 2).