Player compilation in with Mex
Show older comments
Hi,
Player, a robot controller server, can be driven by clients. I am trying to compile a client using a librery (playerc++). The compilation completes (which shows that the header files are found), but the linking failes. This is the code that I use for linking:
mex example0.cpp -v -Iinclude/ -Llib -lplayerc++
The result of the mex is listed below. There seems to be a linking error. Does anyone have an idea about how to solve this linking error?
>> mex example0.cpp -v -Iinclude/ -Llib -lplayerc++
-> Default options filename found in C:\Users\jsteckel\AppData\Roaming\MathWorks\MATLAB\R2010b
----------------------------------------------------------------
-> Options file = C:\Users\jsteckel\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2010b
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments = -Iinclude/
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2010b\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 /incremental:NO /implib:"C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\templib.x" /MAP:"example0.mexw64.map"
LINKDEBUGFLAGS = /DEBUG /PDB:"example0.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"example0.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> cl -Iinclude/ /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\example0.obj -I"C:\Program Files\MATLAB\R2010b"\extern\include /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 example0.cpp
example0.cpp
include/libplayerc++/playerclient.h(127) : warning C4251: 'PlayerCc::PlayerClient::mProxyList' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'PlayerCc::PlayerClient'
with
[
_Ty=PlayerCc::ClientProxy *
]
include/libplayerc++/playerclient.h(129) : warning C4251: 'PlayerCc::PlayerClient::mDeviceList' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'PlayerCc::PlayerClient'
with
[
_Ty=playerc_device_info_t
]
Contents of C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\mex_tmp.rsp:
C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\example0.obj
--> link /out:"example0.mexw64" /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2010b\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 /incremental:NO /implib:"C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\templib.x" /MAP:"example0.mexw64.map" @C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\mex_tmp.rsp lib\playerc++.lib
Creating library C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\templib.x and object C:\Users\jsteckel\AppData\Local\Temp\mex_fSKLsi\templib.exp
example0.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl PlayerCc::PlayerClient::~PlayerClient(void)" (__imp_??1PlayerClient@PlayerCc@@QEAA@XZ) referenced in function mexFunction
example0.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl PlayerCc::Position2dProxy::~Position2dProxy(void)" (__imp_??1Position2dProxy@PlayerCc@@UEAA@XZ) referenced in function mexFunction
example0.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl PlayerCc::Position2dProxy::Position2dProxy(class PlayerCc::PlayerClient *,unsigned int)" (__imp_??0Position2dProxy@PlayerCc@@QEAA@PEAVPlayerClient@1@I@Z) referenced in function mexFunction
example0.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl PlayerCc::PlayerClient::PlayerClient(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,int)" (__imp_??0PlayerClient@PlayerCc@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IH@Z) referenced in function mexFunction
example0.mexw64 : fatal error LNK1120: 4 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'example0.mexw64' failed.
3 Comments
Kaustubha Govind
on 5 May 2011
Is playerc++ a 32- or 64-bit library?
Saurabh Thakur
on 6 May 2011
Does the library playerc++ depend on any other library? If so, you might have to add the dependent libraries in the MEX command as well.
Jan
on 9 May 2011
Answers (1)
Kaustubha Govind
on 9 May 2011
0 votes
If playerc++ is a 32-bit binary, you cannot load it from 64-bit MATLAB MEX Functions. You could either install 32-bit MATLAB on your 64-bit machine, or obtain a 64-bit version of the library.
Categories
Find more on External Language Interfaces 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!