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

Intel Math Kernel Library working with Matlab

ssylee
Beginner
2,165 Views
I have tried to follow the instructions on http://software.intel.com/en-us/articles/using-intel-mkl-with-matlab/, but I'm having problems of getting Intel MKL builder built to be used for Matlab integration (doesn't matter if I used Intel C++ or Fortran compiler)

Fortran compiler error:

C:\Program Files\Intel\MKL\10.1.1.022\tools\builder>nmake ia32

Microsoft Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\\..\\\\ia32\\lib\\
if exist .\temp_cdll rd /q /s .\temp_cdll
Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .\temp_c
dll\*.obj ..\\..\\\\ia32\\lib\\mkl_intel_c.lib ..\\..\\\\ia32\\lib\\mkl_intel
_thread.lib ..\\..\\\\ia32\\lib\\mkl_core.lib ..\\..\\\\ia32\\lib\\mkl_solver.
lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib bufferoverflowu.lib /ou
t:"mkl_custom".dll
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'bufferoverflowu.lib'
NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\link.EXE"' : return code '0x49d'
Stop.


C++ compiler:

C:\Program Files\Intel\MKL\10.1.1.022\tools\builder>nmake ia32

Microsoft Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\\..\\\\ia32\\lib\\
if exist .\temp_cdll rd /q /s .\temp_cdll
Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .\temp_c
dll\*.obj ..\\..\\\\ia32\\lib\\mkl_intel_c.lib ..\\..\\\\ia32\\lib\\mkl_intel
_thread.lib ..\\..\\\\ia32\\lib\\mkl_core.lib ..\\..\\\\ia32\\lib\\mkl_solver.
lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib bufferoverflowu.lib /ou
t:"mkl_custom".dll
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'bufferoverflowu.lib'
NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\link.EXE"' : return code '0x49d'
Stop.


It's not very clear in the instructions on that page of making it work with Matlab. It would be great if someone could help me out with this error.
0 Kudos
8 Replies
ArturGuzik
Valued Contributor I
2,165 Views
Quoting - ssylee
Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .temp_c
dll*.obj ..\..\\ia32\lib\mkl_intel_c.lib ..\..\\ia32\lib\mkl_intel
_thread.lib ..\..\\ia32\lib\mkl_core.lib ..\..\\ia32\lib\mkl_solver.
lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib bufferoverflowu.lib /ou
t:"mkl_custom".dll
It's not very clear in the instructions on that page of making it work with Matlab. It would be great if someone could help me out with this error.

it looks as if you wanted to link to a library which cannot be found (in specified path(s)). As far I as know (but, naturally, might be wrong) the bufferoverflowu.lib is comming from SDK for IA64. The path you specified points to IA32 MKL libs. Why you need that bufferoverflowu.lib? are building for IA64 (then your MKL is wrong)?

A.
0 Kudos
Gennady_F_Intel
Moderator
2,165 Views
Open the Makefile and find out the following lines:

##------------------------------------------------------------------------------
## Comment next line if you get the message:
## "LINK : fatal error LNK1181: cannot open input file 'bufferoverflowu.lib'"
##------------------------------------------------------------------------------
BUF_LIB=bufferoverflowu.lib

Comment this line and try again.
--Gennady

0 Kudos
ssylee
Beginner
2,165 Views
Open the Makefile and find out the following lines:

##------------------------------------------------------------------------------
## Comment next line if you get the message:
## "LINK : fatal error LNK1181: cannot open input file 'bufferoverflowu.lib'"
##------------------------------------------------------------------------------
BUF_LIB=bufferoverflowu.lib

Comment this line and try again.
--Gennady


I followed your suggestion and got rid of that error (also saw this snippet in the makefile). However, I have witnessed the following error, and similar instructions were hardpressed to find anywhere in the MKL directory as well as on the Internet:


C:Program FilesIntelMKL10.1.1.022toolsbuilder>nmake ia32

Microsoft Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\..\\ia32\lib\
if exist .temp_cdll rd /q /s .temp_cdll
Microsoft Library Manager Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft Library Manager Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .temp_c
dll*.obj ..\..\\ia32\lib\mkl_intel_c.lib ..\..\\ia32\lib\mkl_intel
_thread.lib ..\..\\ia32\lib\mkl_core.lib ..\..\\ia32\lib\mkl_solver.
lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib /out:"mkl_custom".dll
Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

user_def_file.def : error LNK2001: unresolved external symbol xerbla
mkl_custom.lib : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:Program FilesMicrosoft Visual Studio 8VCBINl
ink.EXE"' : return code '0x460'
Stop.

0 Kudos
Gennady_F_Intel
Moderator
2,165 Views
Could you add "BUF_LIB=" in command line

below the example I used for checking the problem
nmake ia32 export=_test_list name=_test_dll BUF_LIB=


C:AppsIntelMKL10.1toolsbuilder>nmake ia32 export=_test_list name=_test_dll

C:AppsIntelMKL10.1toolsbuilder>
C:AppsIntelMKL10.1toolsbuilder>nmake ia32 export=_test_list name=_test_dll BUF_LIB=

Microsoft Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\..\\ia32\lib\
if exist .temp_cdll rd /q /s .temp_cdll
Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .temp_cdll*.obj ..\..\
\ia32\lib\mkl_intel_c.lib ..\..\\ia32\lib\mkl_intel_thread.lib ..\..\\ia32\lib\mkl_co
re.lib ..\..\\ia32\lib\mkl_solver.lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib /o
ut:_test_dll.dll
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library _test_dll.lib and object _test_dll.exp

C:AppsIntelMKL10.1toolsbuilder>
--Gennady

0 Kudos
ssylee
Beginner
2,165 Views
Could you add "BUF_LIB=" in command line

below the example I used for checking the problem
nmake ia32 export=_test_list name=_test_dll BUF_LIB=


C:AppsIntelMKL10.1toolsbuilder>nmake ia32 export=_test_list name=_test_dll

C:AppsIntelMKL10.1toolsbuilder>
C:AppsIntelMKL10.1toolsbuilder>nmake ia32 export=_test_list name=_test_dll BUF_LIB=

Microsoft Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\..\\ia32\lib\
if exist .temp_cdll rd /q /s .temp_cdll
Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

link /DLL /MACHINE:IX86 /NODEFAULTLIB /def:user_def_file.def .temp_cdll*.obj ..\..\
\ia32\lib\mkl_intel_c.lib ..\..\\ia32\lib\mkl_intel_thread.lib ..\..\\ia32\lib\mkl_co
re.lib ..\..\\ia32\lib\mkl_solver.lib libiomp5md.lib msvcrt.lib kernel32.lib user32.lib /o
ut:_test_dll.dll
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library _test_dll.lib and object _test_dll.exp

C:AppsIntelMKL10.1toolsbuilder>
--Gennady


This is my output. I don't see anything that you have posted.

C:Program FilesIntelMKL10.1.1.022toolsbuilder>nmake ia32 export=_test_list
name=_test_dll BUF_LIB=

Microsoft Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

set Lib=%Lib%;..\..\\ia32\lib\
The system cannot find the file specified.
NMAKE : fatal error U1077: 'type' : return code '0x1'
Stop.
0 Kudos
ssylee
Beginner
2,165 Views
I have managed to build the mkl_custom.dll and follow the steps in the instructions before opening Matlab R2008b. However, as I checked the output of "version -modules" in Matlab, I can't find an error message listed in that knowledge base page, but I can't find mkl_custom.dll loaded either. I have changed the environmental variable of BLAS_VERSION to be the exact path of mkl_custom.dll. Is it safe to assume that MKL is not loaded on Matlab?
0 Kudos
Gennady_F_Intel
Moderator
2,165 Views

It's unclear - have you built custom dll successfully?
There are two articles in MKL knowledgebase See the info into the link:http://software.intel.com/en-us/forums/showthread.php?t=63436 - probably it helps you

--gif

0 Kudos
ssylee
Beginner
2,165 Views

It's unclear - have you built custom dll successfully?
There are two articles in MKL knowledgebase See the info into the link:http://software.intel.com/en-us/forums/showthread.php?t=63436 - probably it helps you

--gif

I already looked at the KB articles. I don't know how to verify if the custom dll is built successfully. I know that mkl_custom.dll is indeed present in the builder directory. I set up BLAS_VERSION and OMP_NUM_THREADS to be what was recommended in the KB article, but I can't run Matlab with the modules loaded, particularly when I tried to multiply 2 large size matrices, for example (i.e. 100 x 100 matrices). I can multiply the 2 matrices in Matlab when I removed those two environment variables from the system, which led me to this question. It would be much appreciated to hear more recommendations to get MKL working with Matlab. Thanks.
0 Kudos
Reply