- -I (upper case I) to specify the path to the header (sounds like you got this already)
- -L (upper case L) to specify the path to the .LIB file, not the .DLL
- -l (lower case L) to specific the name of the .LIB file (or name the library file on the command-line without -l)
mex with shared library VS 2008
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Problem: I am trying to compile a .cpp file which has some functions which are defined in a DLL. When I try to compile this .cpp I get following error. The DLL and the .lib is in the same directory.
ConvertCAMbToXML.obj : error LNK2019: unresolved external symbol FBRConvertCAMbToXML referenced in function mexFunction
The function FBRConvertCAMbToXML() is defined in DLL and declared in a header which is included in the .cpp which I am trying to compile. Also included with -I option in mex command. My mex command is like,
mex -v -I'.\Inc' -L'.\Release' -lFileReader -outdir '.\MexSrc\Release' '.\MexSrc\ConvertCAMbToXML.cpp'
\Inc has all the header files. \Release has DLL and .lib. \MexSrc has the .cpp which I am compiling.
More details.....
Shared library: I have a visual studio project which has 7 headers and 3 .cpp files. This project produces a DLL. There are some functions which are declared as extern "C". These functions are then used in a .cpp file with mex wrapper. The header file which has the DLL functions declared is included in this mex wrapper file.
Environment: I am using windows 7 64 bit OS. I am compiling DLL using visual studio 2008 SP. I am using Matlab R2010b 64 bit.
Tried so far: I have tried including all possible directories and files with -L, -l, -I options. Tried changing linker settings in the project. Reading existing question-answer posts :p
0 comentarios
Respuestas (1)
Ken Atwell
el 19 de Jul. de 2013
It sounds like you have the right idea. You will need:
Then, the .DLL must also be on the path visible to MATLAB -- addpath as necessary.
If this does not work, please update your question with the exact command line you are issuing to MEX.
Ver también
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!