OpenMP + linux - GOMP_4.0 not found

11,380

Solution 1

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).

Solution 2

Installing correct new library from here http://packages.ubuntu.com/search?keywords=libgomp1 helped me in similar situation.

Share:
11,380
Yurkee
Author by

Yurkee

Updated on August 21, 2022

Comments

  • Yurkee
    Yurkee over 1 year

    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?

    • Harald
      Harald over 7 years
      Is it possible that you have two gnu compiler installations in the system?
    • Yurkee
      Yurkee over 7 years
      Yes indeed, there is 4.3.x and 4.9.4 (which is displayed when i write gcc -v)
    • Harald
      Harald over 7 years
      So is it possible that you're using libgomp library from gcc 4.3 (which didn't support OpenMP 4.0) and not using the libgomp library from gcc 4.9 (in which gcc inclluded support for OpenMP 4.0). Can you search for other libgomp.so in your disk (or better in gcc 4.9 installation path)?
  • Yurkee
    Yurkee over 7 years
    thank you. both solutions work, while the second one with modifying LD_LIBRARY_PATH is better due to fact it does not limit my libraries just to static ones. command that worked: > g++-5.2.0 -std=c++11 -o a.exe -fopenmp ./a.cpp -Wl,-rpath,$HOME/gcc/gcc-4.9.4/lib64/
  • Harald
    Harald over 7 years
    Yes, you can also embed the LD_LIBRARY_PATH for libgomp (or any other shared library) using -rpath. That approach is particularly cleaner. I'll update my answer with it. Thanks!