I found the problem, the SDK I was using had a 32bit library file. When I used the 32-bit version of Matlab 2014b I didn't have any linking problems.
MEX C++ LNK2019: Unresolved External Symbol
1 次查看(过去 30 天)
显示 更早的评论
Hi there,
I've written two files, CanonSlrServer.cpp and CanonSlrServer.h. They compile and run in Visual Studio 2013. I'm using Matlab 2014b.
Inside of my matlab directory I have a library folder that has my .lib file, a header folder with my header files and a Dll folder with my Dlls.
I specify the name and directory for my library files but I'm still getting a linking error. I've tried moving the lib file to the same directory as my cpp, but that doesn't seem to help either.
Thanks for your comments! Ashley
mex -win64 -v CanonSlrServer.cpp -LC:\work\Library -lEDSDK
------------------------------------------------------------------- Compiler location: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\ Options file: C:\Users\apenn\AppData\Roaming\MathWorks\MATLAB\R2014b\mex_C++_win64.xml CMDLINE100 : cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2014b\extern\include" -I"C:\Program Files\MATLAB\R2014b\simulink\include" C:\work\CanonSlrServer.cpp /FoC:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj CMDLINE200 : link /nologo /manifest /DLL /EXPORT:mexFunction C:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj EDSDK.lib /LIBPATH:C:\work\Library /LIBPATH:"C:\Program Files\MATLAB\R2014b\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:CanonSlrServer.mexw64 CMDLINE250 : mt -outputresource:CanonSlrServer.mexw64;2 -manifest CanonSlrServer.mexw64.manifest CMDLINE300 : del CanonSlrServer.exp CanonSlrServer.lib CanonSlrServer.mexw64.manifest CanonSlrServer.ilk COMPILER : cl COMPFLAGS : /Zp8 /GR /W3 /EHs /nologo /MD 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\R2014b\extern\include" -I"C:\Program Files\MATLAB\R2014b\simulink\include" DEBUGFLAGS : /Z7 LINKER : link LINKFLAGS : /nologo /manifest LINKTYPE : /DLL LINKEXPORT : /EXPORT:mexFunction LINKLIBS : EDSDK.lib /LIBPATH:C:\work\Library /LIBPATH:"C:\Program Files\MATLAB\R2014b\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:"CanonSlrServer.mexw64.pdb" LINKOPTIMFLAGS : OBJEXT : .obj LDEXT : .mexw64 SETENV : set COMPILER=cl set COMPFLAGS=/c /Zp8 /GR /W3 /EHs /nologo /MD /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 libEDSDK.lib EDSDK.lib /LIBPATH:C:\work\Library /LIBPATH:"C:\Program Files\MATLAB\R2014b\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%" VCROOT : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC SDKROOT : C:\Program Files (x86)\Windows Kits\8.1\ VSINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\ VCINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ PROF_ENV : C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe VCVARSALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC MATLABROOT : C:\Program Files\MATLAB\R2014b ARCH : win64 SRC : C:\work\CanonSlrServer.cpp OBJ : C:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj OBJS : C:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj SRCROOT : C:\work\CanonSlrServer DEF : C:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.def EXP : CanonSlrServer.exp LIB : CanonSlrServer.lib EXE : CanonSlrServer.mexw64 ILK : CanonSlrServer.ilk MANIFEST : CanonSlrServer.mexw64.manifest TEMPNAME : CanonSlrServer EXEDIR : EXENAME : CanonSlrServer OPTIM : /O2 /Oy- /DNDEBUG LINKOPTIM : ------------------------------------------------------------------- Building with 'Microsoft Visual C++ 2013 Professional'. cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2014b\extern\include" -I"C:\Program Files\MATLAB\R2014b\simulink\include" C:\work\CanonSlrServer.cpp /FoC:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj CanonSlrServer.cpp
link /nologo /manifest /DLL /EXPORT:mexFunction C:\Users\apenn\AppData\Local\Temp\mex_854092491632139_11872\CanonSlrServer.obj EDSDK.lib /LIBPATH:C:\work\Library /LIBPATH:"C:\Program Files\MATLAB\R2014b\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:CanonSlrServer.mexw64 Error using mex Creating library CanonSlrServer.lib and object CanonSlrServer.exp CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsInitializeSDK referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsTerminateSDK referenced in function "public: void __cdecl CanonSLRServer::close(void)" (?close@CanonSLRServer@@QEAAXXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsRelease referenced in function "public: void __cdecl CanonSLRServer::close(void)" (?close@CanonSLRServer@@QEAAXXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsGetChildCount referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsGetChildAtIndex referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsSetPropertyData referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsGetCameraList referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsGetDeviceInfo referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsOpenSession referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsCloseSession referenced in function "public: void __cdecl CanonSLRServer::close(void)" (?close@CanonSLRServer@@QEAAXXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsSendCommand referenced in function "public: int __cdecl CanonSLRServer::captureToFileRequest(char const *)" (?captureToFileRequest@CanonSLRServer@@QEAAHPEBD@Z) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsSendStatusCommand referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsSetCapacity referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsGetDirectoryItemInfo referenced in function "unsigned long __cdecl downloadImageToFile(struct __EdsObject *,void *)" (?downloadImageToFile@@YAKPEAU__EdsObject@@PEAX@Z) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsDownload referenced in function "unsigned long __cdecl downloadImageToFile(struct __EdsObject *,void *)" (?downloadImageToFile@@YAKPEAU__EdsObject@@PEAX@Z) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsDownloadComplete referenced in function "unsigned long __cdecl downloadImageToFile(struct __EdsObject *,void *)" (?downloadImageToFile@@YAKPEAU__EdsObject@@PEAX@Z) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsCreateFileStream referenced in function "unsigned long __cdecl downloadImageToFile(struct __EdsObject *,void *)" (?downloadImageToFile@@YAKPEAU__EdsObject@@PEAX@Z) CanonSlrServer.obj : error LNK2019: unresolved external symbol __imp_EdsSetObjectEventHandler referenced in function "public: int __cdecl CanonSLRServer::open(void)" (?open@CanonSLRServer@@QEAAHXZ) CanonSlrServer.mexw64 : fatal error LNK1120: 18 unresolved externals
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deploy to C++ Applications Using MATLAB Data API (C++11) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!