Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Unresolved External errors when compiling an S-Funtion in VS2008

Asked by Richard Beranek on 26 Apr 2011

[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

Richard Beranek

Products

No products are associated with this question.

2 Answers

Answer by Richard Beranek on 28 Apr 2011
Accepted answer

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.

0 Comments

Richard Beranek
Answer by 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

Richard Beranek on 26 Apr 2011

Yes I am running a 64-bit system and I have switched the include and library directories for the 64-bit locations.

Additionally VS spits out an error if it cannot find the lib files that are added in the dependencies. So it does not seem like that is the issue.

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.

Kaustubha Govind

Contact us