Search code examples
cjava-native-interfaceruntime-errorundefinedopenmp

JNI: undefined symbol GOMP_parallel


I'm using JNI as an interface between a Scala software and a dynamic native library that we will call libnative.so.

Part of said native code uses openmp to perform some parallel operations. Therefore, when building this dynamic library, I specify '-fopenmp' both as a CFLAG and as a LINKFLAG.

There are no errors during the compile process. However, on run time, I get this one:

java: symbol lookup error: /tmp/jni-5458866585640472540/libnative.so: undefined symbol: GOMP_parallel

When using objdump to explore the symbols contained by the library, the referred one is found, although it seems to be marked as undefined:

$ objdump -TC libnative.so | grep "OMP"
0000000000000000      D  *UND*  0000000000000000              GOMP_parallel

After exploring this error for a while, it seems to me that references to external libraries (such as openmp) have to be, in fact, undefined and loaded on run time. I am also thinking that the JRE is not being able to find such library at execution time on the system.

Would these assumptions be true? How could this problem be fixed?

Thank you all in advance.


Solution

  • Fix:

    When building the dynamic library from several static libraries, we need to add -fopenmp to this process, even if we have already done so for each of said modules.