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?
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.
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:
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?:
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.