I ultimately tracked the problem down. The issue was that I was compiling on a 64 bit system. This meant I had to configure the compiler to target an x64 platform (not use default win32) as well as recompile my own libraries to target an x64 platform. This has resolved the issue and I am able to compile my s-function in both visual studio and using 'mex' command in matlab.
Unresolved External errors when compiling an S-Funtion in VS2008
2 views (last 30 days)
Show older comments
[EDIT: 20110609 23:06 CDT - reformat - WDR]
I am trying to compile an S-Function using VS 2008.
I have followed the instructions to compile an s-function from
<http://www.mathworks.com/support/solutions/en/data/1-5Q6YOE/index.html?product=ML&solution=1-5Q6YOE> .
I have included the relevant libraries (libmx.lib libmat.lib libmex.lib) their linking directories as well as included "mex.h". However, I still get the following errors from the compiler:
1>Control.obj : error LNK2001: unresolved external symbol _mexWarnMsgTxt
1>Control.obj : error LNK2001: unresolved external symbol _mexCallMATLAB
1>Control.obj : error LNK2001: unresolved external symbol _mxCreateString
1>Control.obj : error LNK2001: unresolved external symbol _mxGetClassID
1>Control.obj : error LNK2001: unresolved external symbol _mxGetPr
1>Control.obj : error LNK2001: unresolved external symbol _mxCreateDoubleMatrix_730
1>Control.obj : error LNK2001: unresolved external symbol _mxIsNumeric
1>Control.obj : error LNK2001: unresolved external symbol _mxIsComplex
1>Control.obj : error LNK2001: unresolved external symbol _mxGetN
1>Control.obj : error LNK2001: unresolved external symbol _mxGetM
1>Control.obj : error LNK2001: unresolved external symbol _mexErrMsgTxt
1>Control.obj : error LNK2001: unresolved external symbol _mxCalloc
0 Comments
Accepted Answer
More Answers (1)
Kaustubha Govind
on 26 Apr 2011
Have you also ensured step 4 (Add "$MATLABROOT\extern\lib\win32\microsoft" in the options Linker->General->Additional Library Directories). Note that if you have 64-bit MATLAB, you need to swap win32 with win64. Double-check that the relevant libraries are present in whatever folder you add to the directories list.
2 Comments
Kaustubha Govind
on 26 Apr 2011
Have you also configured MSVC to target 64-bit platforms (I think it tries to build a 32-bit DLL by default). See http://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.80%29.aspx
Also, set .mexw64 as the extension.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!