Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
318 Views

undefined symbol: __kmpc_global_thread_num

Hello,
I'm trying to compile a shared library on Linux which makes use of OpenMP functionality. When the other application attempts to invoke the library that I've compiled I'm getting a cryptic error...something about an "undefined symbol: __kmpc_global_thread_num." I have a feeling this is somehow related to OpenMP. Has anyone seen this before? If so, any ideas on how to address the issue?
-L
0 Kudos
7 Replies
Highlighted
318 Views

__kmpc_global_thread_numis in the compiler runtime library for openmp. If your shared library depends on one of the compiler runtime library, you need to make it available to the application.
0 Kudos
Highlighted
Black Belt
318 Views

For example,
icc -openmp otherapp.c yourlibrary.so
would link otherapp to both your library and the OpenMP library. As Qale hinted, libiomp5 would need to be available, for example in a directory pointed to by LD_LIBRARY_PATH. So, if icc is installed, the iccvars setting would take care of making it available.
0 Kudos
Highlighted
Beginner
318 Views

Thanks guys, I feel I'm close to the solution. The problem is I know next to nothing about Linux. It's my understanding that I create the .so file in two steps; the first step generates some object files, the second generates the final .so from the object files. Here's what I'm doing at the command line to get the above error:

Set the environment variables by typing this at the command prompt:
"source /opt/intel/Compiler/11.1/059/bin/iccvars.sh ia32"

Now compile. Step 1)
"icpc -O3 -vec-report -openmp -openmp-lib=compat -openmp-link static -I/usr/local/itt/idl71/external -fPIC -c ...my source code files here... /opt/intel/Compiler/11.1/059/lib/ia32/libiomp5.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsremerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsrmerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippmemerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippmmerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsemerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsmerged.a /opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippcore.a /usr/local/itt/idl71/bin/bin.linux.x86/libidl.so /usr/local/itt/idl71/bin/bin.linux.x86/libfreetype2_3_6.so.6 /usr/local/itt/idl71/bin/bin.linux.x86/libXp.so.6 -static"
The code seems to compile just fine. Then, step 2)
"icpc -shared -o MyDll.so ...my source object files here..."
After which I have the .so file in the appropriate directory.
Also, I'm setting the library path like so (I'm very unsure of this so I enter this into the command line after logging on to the Linux box). I suppose I need to append the path to the "libiomp5.a" lib file? If so, what would the final statement look like?:
"export LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/059/ipp/ia32/sharedlib:$LD_LIBRARY_PATH"
0 Kudos
Highlighted
Black Belt
318 Views

Rather than setting LD_LIBRARY_PATH in accordance with the default installation path of a specific icc version, you might consider tying it to the iccvars script. Going forward, there appears to have been a decision to set a uniform path which would be symlinked to the last installed version, including the path to the last installed iccvars.
For some time, the compilers have been set up to discourage linking libiomp5.a, on the premise that it's conducive to mistakes when making .so. Linking a static libiomp5 into your .so creates problems if additional libiomp5 functionality is needed elsewhere, or even if linked again by mistake. The LD_LIBRARY_PATH applies only to the shared libraries, including libiomp5.so.
0 Kudos
Highlighted
Beginner
318 Views

I believe I'm making progress. Now, however, I'm getting the following error:
"/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtl.o: In function '_start': (.text+0x18): undefined reference to 'main'
I'm compiling this as a shared library, though, and as such it has no 'main' entry point. Why would I get such an error? Here's my compiler invocation...anyone see anything that I'm doing wrong?:
icpc -openmp -I/usr/local/itt/idl71/external -fPIC -o MyDll.so -dynamiclib MyDll.cpp ...other source code files here...
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsremerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsrmerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippmemerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippmmerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippiemerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippimerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippvmemerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippvmmerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsemerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippsmerged.a
/opt/intel/Compiler/11.1/059/ipp/ia32/lib/libippcore.a
/usr/local/itt/idl71/bin/bin.linux.x86/libidl.so
/usr/local/itt/idl71/bin/bin.linux.x86/libfreetype2_3_6.so.6
/usr/local/itt/idl71/bin/bin.linux.x86/libXp.so.6
/usr/local/itt/idl71/bin/bin.linux.x86/libXp.so.6
0 Kudos
Highlighted
318 Views

First of all, -dynamiclib is not a valid option for Linux, it's only supported for Mac OS X, so your command line is actually building an executable binary.

I think you want to use -shared, alsosee -static-intel and -shared-intel in thedocumentation.

0 Kudos
Highlighted
Beginner
318 Views

Okay, thanks. "-shared" got it working.
0 Kudos