OMP Abort: Initializing libguide40.dll but found libiomp5md.dll already initialized

Problem : 
OMP abort: Initializing libguide40.dll, but found libiomp5md.dll already initialized.

This can cause performance degradation.

Set environment variable KMP_DUPLICATE_LIB_OK=TRUE if you want your program to continue in this case.

Root Cause : 
Both libiomp5md.dll and libguide40.dll are Intel OpenMP Runtime library. The libiomp5md.dll is new Intel OpenMP* Compatibility library while the libguide40.dll is legacy OpenMP library.  The Intel® IPP 6.x and Intel® Compiler 11.x threading libraries are switching from the legacy OpenMP* run-time library (libguide*) to the compatibility library (libiomp*). 

Note: The static OpenMP library is removed in Intel Parallel Studio 2011. So the problem like OMP abort: Initializing libiomp5mt.lib, but found libiomp5md.dll already initialized is avoidable if within Intel Parallel Studio 2011 and future version. Please see OpenMP library in Parallel Studio 2011


The dynamic library, libguide40.dll, is still included in the current releases for backwards compatibility and will be removed in a future release.

The error is caused by multiple OpenMP libraries were linked in same application. For example, if a application link the libiomp5md.dll from IPP 6.x,  at the same time, it also link other software, e.g third-party library, which link libguide40.dll, then the error arises because of the duplicate initialization of OpenMP Runtime library


Resolution : 

Please remove one of them and keep only one OpenMP runtime library.

We recommend using and distributing libiomp5md.dll (located in the \bin directory), as libguide40 will be obsolete. 

For the third-party library which have used the libguide40.dll from pervious IPP version, in order to avoid such kind of issue, we strongly recommend rebuild the library with libiomp5md.dll. Or check if the third-party library has some version with libiomp5md.dll supported.
 
Otherwise, set environment variable KMP_DUPLICATE_LIB_OK=TRUE  to ignore the library conflict.

Test Case :

Here is a good example,

When build a application using the OpenCV 1.0 with Intel Compiler 11.0 Professional. And we could build it successfully but unable to run it with the following error.

OMP: Error #15: Initializing libiomp5md.dll, but found libguide40.lib already initialized.

There are a few workarounds and solutions on this issue.
1) Rebuild the OpenCV library using ICC 11, which use libiomp5 library, so no more library conflict happens.
2) Delete IPP PATH from system environment variable or runtime environment not to have OpenCV try to use IPP  libraries.
3) Set KMP_DUPLICATE_LIB_OK=TRUE environment variable to ignore the library conflict, which is not really recommended to do though.
4) Use the latest OpenCV whose version is 1.1pre1. This versioned library is built with Microsoft OpenMP library "vcomp.dll" which is compatible with Intel OpenMP library "libiomp5md.dll". So we can use OpenCV + IPP6.x without any errors.

See another similar issue from here  and article for Intel MKL
有关编译器优化的更完整信息,请参阅优化通知