mex link with blas

6 Ansichten (letzte 30 Tage)
John
John am 13 Feb. 2015
Beantwortet: Geoff Hayes am 14 Feb. 2015
I get the following errors when using mex
>> mex -v fmpc_sim.c
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... Looking for compiler 'Microsoft Windows SDK 7.1 (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1' InstallationFolder ...Yes ('C:\Program Files\Microsoft SDKs\Windows\v7.1\').
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 10.0 ...Yes ('c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\').
... Looking for file 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'c:\Program Files (x86)\Microsoft Visual Studio 10.0' ...Yes.
Found installed compiler 'Microsoft Windows SDK 7.1 (C)'.
Options file details
-------------------------------------------------------------------
Compiler location: c:\Program Files (x86)\Microsoft Visual Studio 10.0
Options file: C:\Users\VorwaldJG\AppData\Roaming\MathWorks\MATLAB\R2014a\mex_C_win64.xml
CMDLINE100 : cl /c /GR /W3 /EHs /nologo /MD -I"C:\Program Files\MATLAB\R2014a\extern\include" -I"C:\Program Files\MATLAB\R2014a\simulink\include" /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /O2 /Oy- /DNDEBUG C:\Users\VorwaldJG\Documents\working\onr_model_predictive_control\software\fast_mpc-0.0.1\fmpc_sim.c /FoC:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj
CMDLINE200 : link /nologo /manifest /DLL /EXPORT:mexFunction C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj /LIBPATH:"C:\Program Files\MATLAB\R2014a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:fmpc_sim.mexw64
CMDLINE250 : mt -outputresource:fmpc_sim.mexw64;2 -manifest fmpc_sim.mexw64.manifest
CMDLINE300 : del C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj fmpc_sim.exp fmpc_sim.lib fmpc_sim.mexw64.manifest fmpc_sim.ilk
COMPILER : cl
COMPFLAGS : /GR /W3 /EHs /nologo /MD -I"C:\Program Files\MATLAB\R2014a\extern\include" -I"C:\Program Files\MATLAB\R2014a\simulink\include" /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE
COMPDEFINES : /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE
MATLABMEX : /DMATLAB_MEX_FILE
OPTIMFLAGS : /O2 /Oy- /DNDEBUG
INCLUDE : -I"C:\Program Files\MATLAB\R2014a\extern\include" -I"C:\Program Files\MATLAB\R2014a\simulink\include"
DEBUGFLAGS : /Z7
LINKER : link
LINKFLAGS : /nologo /manifest
LINKTYPE : /DLL
LINKEXPORT : /EXPORT:mexFunction
LINKLIBS : /LIBPATH:"C:\Program Files\MATLAB\R2014a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
LINKDEBUGFLAGS : /debug /PDB:"fmpc_sim.mexw64.pdb"
LINKOPTIMFLAGS :
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=cl
set COMPFLAGS=/c /GR /W3 /EHs /nologo /MD -I"C:\Program Files\MATLAB\R2014a\extern\include" -I"C:\Program Files\MATLAB\R2014a\simulink\include" /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /DMATLAB_MEX_FILE
set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
set DEBUGFLAGS=/Z7
set LINKER=link
set LINKFLAGS=/nologo /manifest /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\MATLAB\R2014a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /EXPORT:mexFunction
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
SDKROOT : C:\Program Files\Microsoft SDKs\Windows\v7.1\
VSROOT : c:\Program Files (x86)\Microsoft Visual Studio 10.0
MATLABROOT : C:\Program Files\MATLAB\R2014a
ARCH : win64
SRC : C:\Users\VorwaldJG\Documents\working\onr_model_predictive_control\software\fast_mpc-0.0.1\fmpc_sim.c
OBJ : C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj
OBJS : C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj
SRCROOT : C:\Users\VorwaldJG\Documents\working\onr_model_predictive_control\software\fast_mpc-0.0.1\fmpc_sim
DEF : C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.def
EXP : fmpc_sim.exp
LIB : fmpc_sim.lib
EXE : fmpc_sim.mexw64
ILK : fmpc_sim.ilk
MANIFEST : fmpc_sim.mexw64.manifest
TEMPNAME : fmpc_sim
EXEDIR :
EXENAME : fmpc_sim
OPTIM : /O2 /Oy- /DNDEBUG
LINKOPTIM :
-------------------------------------------------------------------
Building with 'Microsoft Windows SDK 7.1 (C)'.
Set PATH = c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\VCPackages;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Bin\x64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Bin;;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Tumbleweed\Desktop Validator\;C:\Program Files\ActivIdentity\ActivClient\;C:\Program Files (x86)\ActivIdentity\ActivClient\;C:\Program Files (x86)\MATLAB\R2014a\runtime\win32;C:\Program Files (x86)\MATLAB\R2014a\bin;C:\Program Files\MATLAB\R2014a\runtime\win64;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\TortoiseSVN\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\R\R-3.1.1\bin\x64
Set INCLUDE = c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE\gl;C:\Program Files\MATLAB\R2014a\extern\include;;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE\gl;C:\Program Files\MATLAB\R2014a\extern\include;;
Set LIB = c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Lib\X64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2014a\lib\win64;C:\Program Files\MATLAB\R2014a\extern\lib\win64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Lib\X64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2014a\lib\win64;C:\Program Files\MATLAB\R2014a\extern\lib\win64;
Set LIBPATH = c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\LIB\X64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2014a\extern\lib\win64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\LIB\X64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2014a\extern\lib\win64;
cl /c /GR /W3 /EHs /nologo /MD -I"C:\Program Files\MATLAB\R2014a\extern\include" -I"C:\Program Files\MATLAB\R2014a\simulink\include" /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /O2 /Oy- /DNDEBUG C:\Users\VorwaldJG\Documents\working\onr_model_predictive_control\software\fast_mpc-0.0.1\fmpc_sim.c /FoC:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj
fmpc_sim.c
link /nologo /manifest /DLL /EXPORT:mexFunction C:\Users\VORWAL~1\AppData\Local\Temp\1\mex_32143412800360_6452\fmpc_sim.obj /LIBPATH:"C:\Program Files\MATLAB\R2014a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:fmpc_sim.mexw64
Error using mex
Creating library fmpc_sim.lib and object fmpc_sim.exp
fmpc_sim.obj : error LNK2019: unresolved external symbol dgemv_ referenced in function dnudz
fmpc_sim.obj : error LNK2019: unresolved external symbol dtrsv_ referenced in function dnudz
fmpc_sim.obj : error LNK2019: unresolved external symbol dgemm_ referenced in function dnudz
fmpc_sim.obj : error LNK2019: unresolved external symbol dtrtrs_ referenced in function dnudz
fmpc_sim.obj : error LNK2019: unresolved external symbol dposv_ referenced in function dnudz
fmpc_sim.obj : error LNK2019: unresolved external symbol daxpy_ referenced in function rdrp
fmpc_sim.obj : error LNK2019: unresolved external symbol dnrm2_ referenced in function resdresp
fmpc_sim.mexw64 : fatal error LNK1120: 7 unresolved externals
  1 Kommentar
John
John am 13 Feb. 2015
Same errors when using
mex fmpc_sim.c libmwblas.lib libmwblascompat32.lib

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Geoff Hayes
Geoff Hayes am 14 Feb. 2015
John - I think that you have to explicitly link to the libraries rather than just passing in the lib names, i.e. use the -l option. If I take the matrixMultiply.c example from calling lapack and blas, and try to build/compile it as just
mex matrixMultiply.c
I observe the error
error LNK2019: unresolved external symbol _dgemm referenced in function _mexFunction
However, if I compile and link to the library as
mex matrixMultiply.c -lmwblaslib
then the result is
Building with 'Microsoft Windows SDK 7.1 ©'.
MEX completed successfully
Try doing it as above and see what happens!

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by