mex with shared library VS 2008

6 ビュー (過去 30 日間)
sarvesh
sarvesh 2013 年 7 月 19 日
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

回答 (1 件)

Ken Atwell
Ken Atwell 2013 年 7 月 19 日
It sounds like you have the right idea. You will need:
  • -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)
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.
  1 件のコメント
sarvesh
sarvesh 2013 年 7 月 19 日
Thank you. I just updated my question with my mex command.
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by