Linking Error using Mex
Show older comments
I have a long list of code distributed over multiple directories. I have written a mex function to access these cpp code from Matlab. I am using the following command to compile and link it:
mex -c test_ARGUS.cpp -IC:/Argus ... -IC:/Platform ... -IC:/sigint ... -IC:/SimpleWAMI ... -IC:/Tracker ... -IC:/utils ... -IC:/Ground_Movers;
which compiles without any error
But when I do the above without "-c", it generates the following linking error: Any help?
Creating library C:\Users\NILANJ~2.DAS\AppData\Local\Temp\mex_i18Q7G\templib.x and object C:\Users\NILANJ~2.DAS\AppData\Local\Temp\mex_i18Q7G\templib.exp
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: __cdecl Ve_Argus_sensor_system::~Ve_Argus_sensor_system(void)" (??1Ve_Argus_sensor_system@@QEAA@XZ) referenced in function mexFunction
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: __cdecl Ve_platform::~Ve_platform(void)" (??1Ve_platform@@QEAA@XZ) referenced in function mexFunction
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: void __cdecl Ve_Argus_sensor_system::initialize(class Ve_Argus_sensor_system_init &)" (?initialize@Ve_Argus_sensor_system@@QEAAXAEAVVe_Argus_sensor_system_init@@@Z) referenced in function mexFunction
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: __cdecl Ve_Argus_sensor_system_init::Ve_Argus_sensor_system_init(void)" (??0Ve_Argus_sensor_system_init@@QEAA@XZ) referenced in function mexFunction
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: __cdecl Ve_platform::Ve_platform(void)" (??0Ve_platform@@QEAA@XZ) referenced in function mexFunction
test_ARGUS_offlineMex.obj : error LNK2019: unresolved external symbol "public: __cdecl Ve_Argus_sensor_system::Ve_Argus_sensor_system(void)" (??0Ve_Argus_sensor_system@@QEAA@XZ) referenced in function mexFunction
test_ARGUS_offlineMex.mexw64 : fatal error LNK1120: 6 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'test_ARGUS.mexw64' failed.
Answers (1)
Kaustubha Govind
on 13 Nov 2012
0 votes
You need to link against the object/library files that contain the definition of Ve_Argus_sensor_system, etc. You can simply tag on additional .obj or .c files to the mex command (right after your file name test_ARGUS.cpp), or use the -l option to link against libraries.
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!