Why do I receive error LNK2019 using mex to link to "C" dll
2 views (last 30 days)
Show older comments
I am trying to compile a mex function to call functions from a set of commercial "C" dll's with an associated .lib file. I am using the following script to execute the mex command:
--------------- script -------------------
% include path bvHeaderPath = 'C:\Program Files (x86)\BlueView\ProViewer SDK 3.6\include'; iPath = ['-I' bvHeaderPath];
% blueview library path %bvLibPath = 'C:\Program Files (x86)\BlueView\ProViewer SDK 3.6\lib'; bvLibPath = 'C:\home\stockel\matlab\mex\blueview'; lPath = ['-L' bvLibPath];
mex('-v', iPath, '-lbvtsdk3', lPath, 'mex_file_sonar.cpp');
----------- end script ------------------
And the result is:
------------ mex output -----------------------
--> cl -I"C:\Program Files (x86)\BlueView\ProViewer SDK 3.6\include" /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\mex_file_sonar.obj -I"C:\Program Files\MATLAB\R2013b\extern\include" -I"C:\Program Files\MATLAB\R2013b\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 mex_file_sonar.cpp
mex_file_sonar.cpp Contents of C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\mex_tmp.rsp: C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\mex_file_sonar.obj
--> link /out:"mex_file_sonar.mexw64" /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\templib.x" /MAP:"mex_file_sonar.mexw64.map" @C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\mex_tmp.rsp C:\home\stockel\matlab\mex\blueview\bvtsdk3.lib
Creating library C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\templib.x and object C:\Users\STOCKE~1.IT1\AppData\Local\Temp\1\mex_8gw18h\templib.exp
mex_file_sonar.obj : error LNK2019: unresolved external symbol __imp_BVTSonar_Destroy referenced in function mexFunction
mex_file_sonar.obj : error LNK2019: unresolved external symbol __imp_BVTPing_Destroy referenced in function mexFunction
... lines deleted for brevity ...
mex_file_sonar.mexw64 : fatal error LNK1120: 23 unresolved externals
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'mex_file_sonar.mexw64' failed.
Unable to complete successfully.
Error in bvCompile (line 14) mex('-v', iPath, '-lbvtsdk3', lPath, 'mex_file_sonar.cpp');
--------------- end mex output ----------------------
I have used the DUMPBIN utility on the .lib file to make sure the symbols are present, with output:
---------- DUMPBIN output -------------------------
File Type: LIBRARY
Exports
ordinal name
_BVTSonar_Destroy
_BVTPing_Destroy
... lines deleted for brevity
-------------- end DUMPBIN output ---------------------
So the library contains the symbols. Why do I have unresolved references?
Thanks, Jim
3 Comments
Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!