Sorry, forgot to ask if anyone knows why it's failing or has any possible solutions to try. Thanks a ton for the help!
mex compile linking failure
4 views (last 30 days)
Show older comments
[EDIT: 20110711 16:37 CDT - reformat - WDR]
I am trying to compile a legacy code originally written in FORTRAN and converted to C using 'f2c.exe' into an S-function for use in SIMULINK. Previously people have been able to compile the code (on older versions of MATLAB), and now I'm trying to recompile to code. I get a linking error:
C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Link of 'myProgram.mexw32' failed.
The verbose output from the compiler follows:
mex myProgram.c haspms32.obj hasp32b.obj -v
This is mex, Copyright 1984-2007 The MathWorks, Inc.
-> Default options filename found in C:\Users\UsrName\AppData\Roaming\MathWorks\MATLAB\R2009a
----------------------------------------------------------------
-> Options file = C:\Users\UsrName\AppData\Roaming\MathWorks\MATLAB\R2009a\mexopts.bat
MATLAB = C:\PROGRA~1\MATLAB\R2009A
-> COMPILER = lcc
-> Compiler flags:
COMPFLAGS = -c -Zp8 -I"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup
OPTIMFLAGS = -DNDEBUG
DEBUGFLAGS = -g4
arguments =
Name switch = -Fo
-> Pre-linking commands =
-> LINKER = lcclnk
-> Link directives:
LINKFLAGS = -tmpdir "." -dll "C:\PROGRA~1\MATLAB\R2009A\extern\lib\win32\lcc\mexFunction.def" -L"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\lib" -libpath "C:\PROGRA~1\MATLAB\R2009A\extern\lib\win32\lcc" "C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\templib2.obj"
LINKDEBUGFLAGS =
LINKFLAGSPOST = libmx.lib libmex.lib libmat.lib
Name directive = -o "myProgram.mexw32"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = lrc -I"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\include" -noregistrylookup -fo"mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> lcc -c -Zp8 -I"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup -FoC:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\myProgram.obj -IC:\PROGRA~1\MATLAB\R2009A\extern\include -IC:\PROGRA~1\MATLAB\R2009A\simulink\include -DNDEBUG -DMX_COMPAT_32 myProgram.c
Warning myProgram.c: .\haspcheck.c: 6 assignment of pointer to const unsigned int to pointer to unsigned long
Warning myProgram.c: .\haspcheck.c: 6 assignment of pointer to const unsigned int to pointer to unsigned long
Warning myProgram.c: 139 local `array 80 of char token' is not referenced
Warning myProgram.c: 137 possible usage of timeout before definition
Warning myProgram.c: 128 local `int timesig' is not referenced
0 errors, 5 warnings
--> lcc -c -Zp8 -I"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup "C:\PROGRA~1\MATLAB\R2009A\sys\lcc\mex\lccstub.c" -Fo"C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\templib2.obj"
Contents of C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\mex_tmp.rsp:
C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\myProgram.obj haspms32.obj hasp32b.obj
--> lcclnk -o "myProgram.mexw32" -tmpdir "." -dll "C:\PROGRA~1\MATLAB\R2009A\extern\lib\win32\lcc\mexFunction.def" -L"C:\PROGRA~1\MATLAB\R2009A\sys\lcc\lib" -libpath "C:\PROGRA~1\MATLAB\R2009A\extern\lib\win32\lcc" "C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\templib2.obj" -s @C:\USERS\UsrName\APPDATA\LOCAL\TEMP\MEX_0W~1\MEX_TMP.RSP libmx.lib libmex.lib libmat.lib
C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Link of 'myProgram.mexw32' failed.
??? Error using ==> mex at 218
Unable to complete successfully.
Accepted Answer
Walter Roberson
on 11 Jul 2011
That Link failed message isn't very helpful, is it?
I think I would be tempted to download the appropriate Microsoft SDK for your release, in hopes that a more useful error message was generated.
3 Comments
Kaustubha Govind
on 12 Jul 2011
John: If you look at the list of compilers on Walter's link above, MSVC 2010 is not a supported compiler for R2009a. You can either upgrade to R2011a or get a supported version of MSVC.
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler 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!