Libgomp.so.1: Unable to open shared objects file

I am using OpenMP in my C ++ code.

libgomp.so.1 exists in my lib folder. I also added my path to LD_LIBRARY_PATH

Still at runtime I get the error: libgomp.so.1: Unable to open shared objects file

At compile time, I compile my code with the -fopenmp option.

Any idea what might be causing the problem?

thank

+3


source to share


1 answer


Use static links for your program. In your case, this means using -fopenmp -static

and, if necessary, specifying the full paths to the corresponding libraries librt.a

and libgomp.a

.

This solves your problem as a static link just packages all the code needed to run your program along with your binary. Therefore, your target system does not need to look for any dynamic libraries, it doesn't even matter if they are present on the target system.



Note that static binding is not a miracle cure. For your specific problem with a strange hardware emulator, this should be a good approach. In general, however, there are (at least) two lower levels for static binding:

  • binary size. Imagine linking all of your KDE programs statically, so you have essentially hundreds of copies of all KDE / QT libraries on your system, if you can only have one if you use shared libraries.
  • update paths. Let's say people find a security issue in a library x

    . In shared libraries, this is sufficient if you just update the library as soon as a patch is available. If all of your applications were statically linked, you will have to wait for all these developers to reconfigure and re-release their applications.
+2


source







All Articles