mex compile linking failure

2 次查看(过去 30 天)
[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.
  1 个评论
John Robinson
John Robinson 2011-7-11
Sorry, forgot to ask if anyone knows why it's failing or has any possible solutions to try. Thanks a ton for the help!

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2011-7-11
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.
You can find the list of compilers for 2009a here
  3 个评论
Kaustubha Govind
Kaustubha Govind 2011-7-12
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.
John Robinson
John Robinson 2011-7-12
Walter and Kaustubha,
Thanks a lot for the help, I tried VC++ 2008 and the program compiled successfully! Thanks a ton!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by