Why do I receive error LNK2019 using mex to link to "C" dll

2 次查看(过去 30 天)
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 个评论
Jim Stockel
Jim Stockel 2014-6-27
The DUMPBIN output does not contain any "_imp" sysmbols. I noticed this, but am not familiar enough with the link process to know whether the "_BVT" symbols would satisfy the "_imp_BVT" symbols. Apparently not. Is this some library incompatability?
Jim Stockel
Jim Stockel 2014-6-30
Based on the recommendation of the producer of the commercial library I am using, I will try to do this using the capabilities of matlab to directly access the libarary using loadlib and related functions. Thanks to those who attempted to help.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by