6

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?

Yurkee
  • 795
  • 2
  • 9
  • 23
  • Is it possible that you have two gnu compiler installations in the system? – Harald Aug 18 '16 at 12:35
  • Yes indeed, there is 4.3.x and 4.9.4 (which is displayed when i write gcc -v) – Yurkee Aug 18 '16 at 13:25
  • 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)? – Harald Aug 18 '16 at 13:32

2 Answers2

6

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).
Harald
  • 3,110
  • 1
  • 24
  • 35
  • 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/ – Yurkee Aug 23 '16 at 13:17
  • 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! – Harald Aug 23 '16 at 13:52
1

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

Anna Vergeles
  • 125
  • 1
  • 10