Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Mark_Rubelmann
Beginner
221 Views

Linker errors when statically linking multithreaded IPP with MS compiler

Jump to solution
Hi,

I'm trying to use the multithreaded statically linked libraries but it just isn't working! I'm using Visual Studio 2008 with Microsoft's compiler and IPP 7.0.2. My current theory is that I'm getting linker conflicts between the Intel and MS OpenMP implementations. I don't know what parts of this are relevant, but I'm trying to build a DLL that uses IPP. My DLL uses some DLLs from the UIC sample, several static libraries, and one static library that also uses IPP. For the sake of this discussion, I'll call my DLL Foo.dll and my static library that uses IPP Bar.lib. At first I had my Foo.dll project link against the UIC stublibs and defined _IPP_PARALLEL_STATIC instead of specifying the IPP libraries that I need. Bar.lib doesn't have any IPP libraries specified in the librarian section, nor does it have _IPP_PARALLEL_STATIC defined. That resulted in the following linker errors:

  • libiomp5mt.lib(kmp_global.obj) : error LNK2005: __You_must_link_with_exactly_one_OpenMP_library already defined in VCOMPD.lib(unique.obj)
  • libiomp5mt.lib(kmp_global.obj) : error LNK2005: __You_must_link_with_Microsoft_OpenMP_library already defined in VCOMPD.lib(unique.obj)

Defining _IPP_PARALLEL_STATIC in Bar.lib doesn't change anything.

If I put the IPP libraries that I need in Foo.dll instead of using _IPP_PARALLEL_STATIC (I need ippcore_t.lib, ippi_t.lib, ipps_t.lib, ippj_t.lib, and ippcc_t.lib), I get 183 errors that are things like these:

  • ippi_t.lib(pifixedt7ca_split_g9_ownippiFilterLowpass5x5.obj) : error LNK2019: unresolved external symbol ___kmpc_master referenced in function _g9_ownippiFilterLowpass5x5
  • ippi_t.lib(pifixedt7ca_split_g9_ownippiFilterLowpass5x5.obj) : error LNK2019: unresolved external symbol ___kmpc_end_master referenced in function _g9_ownippiFilterLowpass5x5
  • ippi_t.lib(pifixedt7ca_split_g9_ownippiFilterLowpass5x5.obj) : error LNK2019: unresolved external symbol ___kmpc_barrier referenced in function _g9_ownippiFilterLowpass5x5
  • ippj_t.lib(pjdeccc0_split_g9_ippiYCbCrToRGB_JPEG_8u_P3C3R.obj) : error LNK2019: unresolved external symbol ___kmpc_global_thread_num referenced in function _g9_ippiYCbCrToRGB_JPEG_8u_P3C3R@24
  • ...lots more ___kmpc things...
  • ipps_t.lib(pscopyca_split_px_ownsCopy_8u.obj) : error LNK2019: unresolved external symbol __intel_fast_memcpy referenced in function _px_ownsCopy_8u

Next I tried including libiomp5mt.lib which gave several OpenMP function errors:

  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_get_num_threads already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_in_parallel already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_init_lock already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_get_thread_num already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_set_lock already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_unset_lock already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • VCOMPD.lib(VCOMP90D.DLL) : error LNK2005: _omp_get_max_threads already defined in libiomp5mt.lib(kmp_ftn_extra.obj)
  • ipps_t.lib(pscopyca_split_px_ownsCopy_8u.obj) : error LNK2019: unresolved external symbol __intel_fast_memcpy referenced in function _px_ownsCopy_8u

After that I set it to ignore VCOMPD.lib and I got more OpenMP errors but this time they had the name of my static library in there:

  • Bar.lib(openmpwrappers.obj) : warning LNK4217: locally defined symbol _omp_get_num_threads imported in function "int __cdecl di_openmp::GetNumberOfThreads(void)" (?GetNumberOfThreads@di_openmp@@YAHXZ)
  • etc...
  • ipps_t.lib(pscopyca_split_px_ownsCopy_8u.obj) : error LNK2019: unresolved external symbol __intel_fast_memcpy referenced in function _px_ownsCopy_8u

Making Bar.lib ignore VCOMPD.lib doesn't change anything either. I can't think of anything else to try. Does anyone have any suggestions?

Thanks,
Mark

0 Kudos
1 Solution
PaulF_IntelCorp
Employee
221 Views
Hello Mark,

Yes, you're experiencing a conflict between the Microsoft OpenMP library (VCOMPD.LIB) and the Intel OpenMP library (libiomp5*.lib). You can only use one or the other within your application, they cannot be used side-by-side.

I think what is happening is being caused by some automatic references to these libraries on the link command line of your projects. I'm assuming that some of your code contains explicit references to either #include "omp.h" and #pragma OMP... which is causing the Microsoft compiler tothen automatically specify a link against theMicrosoft OMP library. Likewise, the Intel IPP libraries you are using (by specifying_IPP_PARALLEL_STATIC) are pulling in the Intel OMP libraries.

Since you must use the Intel OMP libraries with the IPP library, I recommend that you follow the instructions in the following Microsoft KB to disable the automatic link to the Microsoft OMP library files:

http://msdn.microsoft.com/en-us/library/0h7x01y0(v=VS.90).aspx

and then it should work. You may have to add in manually a few other Microsoft libraries as a result of using the /nodefaultlib switch, as specified above, but this should eliminate the conflict.

The other thing to check is which IPP functions you are using in your custom lib. Only 15-20% of the IPP functions are actually multi-threaded. So if the functions you are using are not on the list (see "...\Documentation\en_US\ipp\ThreadedFunctionsList.txt") you could also just use the single-threaded static lib to build your IPP DLL, by specifying _IPP_SEQUENTIAL_STATIC).

Hope this helps,

Paul

View solution in original post

5 Replies
PaulF_IntelCorp
Employee
222 Views
Hello Mark,

Yes, you're experiencing a conflict between the Microsoft OpenMP library (VCOMPD.LIB) and the Intel OpenMP library (libiomp5*.lib). You can only use one or the other within your application, they cannot be used side-by-side.

I think what is happening is being caused by some automatic references to these libraries on the link command line of your projects. I'm assuming that some of your code contains explicit references to either #include "omp.h" and #pragma OMP... which is causing the Microsoft compiler tothen automatically specify a link against theMicrosoft OMP library. Likewise, the Intel IPP libraries you are using (by specifying_IPP_PARALLEL_STATIC) are pulling in the Intel OMP libraries.

Since you must use the Intel OMP libraries with the IPP library, I recommend that you follow the instructions in the following Microsoft KB to disable the automatic link to the Microsoft OMP library files:

http://msdn.microsoft.com/en-us/library/0h7x01y0(v=VS.90).aspx

and then it should work. You may have to add in manually a few other Microsoft libraries as a result of using the /nodefaultlib switch, as specified above, but this should eliminate the conflict.

The other thing to check is which IPP functions you are using in your custom lib. Only 15-20% of the IPP functions are actually multi-threaded. So if the functions you are using are not on the list (see "...\Documentation\en_US\ipp\ThreadedFunctionsList.txt") you could also just use the single-threaded static lib to build your IPP DLL, by specifying _IPP_SEQUENTIAL_STATIC).

Hope this helps,

Paul

View solution in original post

PaulF_IntelCorp
Employee
221 Views
Mark,

One more thing, are you setting up the /ignoredefaultlibs when you compile the files that make up the "bar.lib" file?

Paul
Mark_Rubelmann
Beginner
221 Views
Thanks for the help Paul! I've got everything working now. I made Foo.dll, bar.lib, and the UIC dll all ignore vcomp/vcompd and #define _OPENMP_NOFORCE_MANIFEST to make sure it didn't show up in the manifest files. I wound up ditching _IPP_PARALLEL_STATIC and manually linked in the IPP libraries I needed plus libiomp5md.lib and libirc.lib from the compiler redistributables.

-Mark
PaulF_IntelCorp
Employee
221 Views
Mark,

Glad to hear you found a workable solution!

Paul
apolo74
Beginner
221 Views
Hi guys,
my problem seems to be very related to this thread... I've tried Paul's tips but don't seem to work. First of all I have created an application that uses IPP functions, I have created a custom library and everything works well under Linux and MacOS machines without IPP... but in Windows I'm having some linking problems. First I created a customDLL using the ipp-samples example and I obtain myIPP_t.lib and myIPP_t.dll... but when trying to compile a new program using those files I get linking errors in Visual Studio 2010.
In the same folder where I put the previously obtained myIPP_t.lib and myIPP_t.dll, I have copied libmmt.lib, libircmt.lib and libiomp5mt.lib. And in the "Configuration Properties" of the VS project, at "Intel Performance Libraries" > "Use IPP" I'm using the "Multi-threaded Static Library" option (I'm not sure of this either)... I don't have anything like "#pragma OMP..." or "#include "omp.h"" inside my code but I'm still getting:
ippcore_t.lib(ippmrgjump.obj) : error LNK2019: unresolved external symbol _omp_get_num_procs referenced in function _ippStaticInitCpu@4
ippcore_t.lib(ippmrgjump.obj) : error LNK2019: unresolved external symbol _omp_get_max_threads referenced in function _ippStaticInitCpu@4
I have copied ippcore_t.lib and ippcore-7.0.dll into the same folder where the other libraries are but that doesn't help. What should I do? Thanks for any help,
Boris
PS: I also tried the "Ignore Specific Default Libraries" suggestion about vcomp.lib but didn't work.
Reply