How to compile MATLAB MEX file using Mingw-w64 and Intel MKL
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Could someone with experience help me to accomplish the above noble objective please?
After so many hours (rather days) and ways of trying and searching the internet, the frustration has accumulated in me that I decided to turn to the SO community. I hope that a working solution will help also others in such a situation.
My setup:
- Windows 10
- MATLAB R2019b
- Intel MKL for calling the compiled mex files in MATLAB, this particular version of MATLAB uses:
- 'Intel(R) Math Kernel Library Version 2018.0.3 Product Build 20180406 for Intel(R) 64 architecture applications, CNR branch AVX'
- MinGW64 Compiler (C++) for mex file compilation, more precisely:
- x86_64-6.3.0-posix-seh-rt_v5-rev
- Two source cpp files
- Although they are not important now, as the issue does not lie here. (For information only: these files correctly compile with OpenBLAS but this is out of scope.)
I try to use the built-in mex command in MATLAB plus linking the correct Intel MKL libraries as shown below; however, I do not mind using any other setup for compilation. The only restriction what I have to respect is to stay on a Windows 10 platform.
mex -g -DMKL_ILP64 '-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\include' '-LC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win' main.cpp sub.cpp -lmkl_intel_ilp64.lib -lmkl_sequential.lib -lmkl_core.lib
Attempt to compile leads to many error messages as shown at the bottom. This is only a truncated version of the original error message as it would otherwise exceed SO's limitation on allowed character length per question.
Most of errors are either `undefined references` either to
__security_check_cookie
or
__GSHandlerCheck
The actual error message is much longer and keep throwing the similar parts, so I truncated it to avoid further clutter here.
I highly appreciate any help, hint or suggestion. Thank you in advance.
Building with 'MinGW64 Compiler (C++)'.
Error using mex
Warning: .drectve `-defaultlib:"uuid.lib" ' unrecognized
Warning: corrupt .drectve at end of def file
Warning: .drectve `-defaultlib:"uuid.lib" ' unrecognized
Warning: corrupt .drectve at end of def file
Warning: .drectve `-defaultlib:"uuid.lib" ' unrecognized
Warning: corrupt .drectve at end of def file
Warning: .drectve `-defaultlib:"uuid.lib" ' unrecognized
Warning: corrupt .drectve at end of def file
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemm.obj):(.text[dgemm]+0x194): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemm.obj):(.text[dgemm]+0x2a0): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemm.obj):(.xdata+0x1c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemm.obj):(.xdata+0x3c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dsyrk.obj):(.text[dsyrk]+0x14c): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dsyrk.obj):(.text[dsyrk]+0x215): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dsyrk.obj):(.xdata+0x1c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dsyrk.obj):(.xdata+0x3c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_ddot.obj):(.text[ddot]+0x63): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_ddot.obj):(.text[ddot]+0x125): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_ddot.obj):(.xdata+0x8): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_ddot.obj):(.xdata+0x30): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemv.obj):(.text[dgemv]+0x15b): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemv.obj):(.text[dgemv]+0x248): undefined reference to
`__security_check_cookie'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemv.obj):(.xdata+0x1c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgemv.obj):(.xdata+0x3c): undefined reference to `__GSHandlerCheck'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.185\windows\mkl\lib\intel64_win\mkl_intel_ilp64.lib(_dgetrf.obj):(.text[dgetrf]+0xe0): undefined reference to
`__security_check_cookie'
collect2.exe: error: ld returned 1 exit status
2 Kommentare
星宇 周
am 21 Apr. 2022
Same problem and I have got some advice for using Intel OneAPI C++ compiler instead of MinGW, but haven't found out how to do it until now. May I ask that have you solved this problem?
Bruno Luong
am 21 Apr. 2022
I have successully made MATLAB recognize Intel compiler
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Support for MinGW-w64 C/C++ Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!