Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

MKL with MinGW64 compiler


I'm currently evaluating MKL for usage in a MinGW (64 bit) environment. I know that MinGW is not a compiler platform officially supported for MKL, but thought it would be worth a try with MKL for Windows because MinGW's gcc & linker produces just native windows object/lib file formats.

However, when I try to link a small program against MKL (following the link line advisor tool on this site)
I got many undefined references:

c:/mingw-w64-gcc4.7/bin/g++ -L"c:/Program Files (x86)\\Intel\\Composer XE 2011 SP1\\mkl\\lib\\intel64" -o tstmkl t
stmkl.o dgemm.o -lgomp -lwinmm -Wl,--subsystem,console -mwindows

Warning: .drectve `-defaultlib:"uuid.lib" ' unrecognized
libs/mkl/mkl_intel_thread.lib(dgemm_drv.obj):(.text[mkl_blas_dgemm]+0x4b5): undefined reference to `__kmpc_global_thread_num'
libs/mkl/mkl_intel_thread.lib(dgemm_drv.obj):(.text[mkl_blas_dgemm]+0x5d0): undefined reference to `__kmpc_ok_to_fork'
mkl_intel_lp64.lib(_dgemm_lp64.obj):(.text[dgemm]+0x159): undefined reference to `mkl_blas_dgemm'

I think part of the problem could be that MinGw links to the GNU OMP lib (-lgomp) which is probably incompatible to the OMP lib used by MKL ? (please confirm)
However, I also tried to use the non-threaded MKL and still got the undefined reference to mkl_blas_dgemm.

Interestingly, however not all references are undefined. I even managed to succesfully link a very small MKL program using only some timer functions so I still think it should be possible in principle ..

Therefore I would be very interestd if anyone has been able to succesfully use MKL with MinGW64
(The existing threads in the forum about this topic remained inconclusive)

Thanks in advance for any help and suggestions
0 Kudos
2 Replies
Honored Contributor III
I haven't heard of a way to accomplish this.
The Intel libiomp5 for Windows supports Microsoft vcomp calls but not libgomp calls. MKL_intel_thread requires libiomp5. You probably can't run libgomp and libiomp5 together.
There are circular references among those MKL static libraries. Normally, that doesn't bite you when linking with Visual Studio compatibility. For good luck, you might try the _dll libraries, or repeat the list of static libraries (probably 3 times if you put them in order lp64, core, thread).
mingw project doesn't have object level compability with Visual Studio compatible libraries such as MKL. They say they are working in that direction but no time estimate is possible.
0 Kudos
Hi Zx-81,

As we never do MinGW test with MKL, it hard to give a certain conclusion.

But my personalview (as as TimP)

MKL is only compatable with Visual studio compatiable library, include some MSVC run-time library.
And weassume that Mingw project don't have object level compability with Visual studio compatiable library. (do some one can confirm? or Please remove the -lgomp and try
-lwinmm -Wl,--subsystem,console -mwindows

for example, MKL use libiomp5, which is only compilabe with microsoft OpenMP library vcomp, not compitable with libgomp in windows,

The case is like kind ofA~=B, C!=B, So most of possibility, A !=C. even if you may makesome test case run. In princple, it is untworkable.

Maybe i'm wrong, please correct if any one have any more test.

Best Regards,
0 Kudos