MATLAB gives error while generating MEX file from the Fortran source code

조회 수: 2 (최근 30일)
When I try to generate the MEX file from the Fortran source code (TEINITG.F), Matlab always gives errors.After downloading the trial versions of Intel Visual Fortran 11.1 Microsoft Visual C++ 2008 SP1 linker, I used mex -setup to configure the environment. Then I tried to generate mex functions from FORTRAN Source Code (TEINITG.F).
However, when I type: mex TEINITG.F
Matlab shows link errors, like: >>mex TEINITG.F Creating library C:\Users\xue\AppData\Local\Temp\mex_TDkmp3\templib.x and object C:\Users\xue\AppData\Local\Temp\mex_TDkmp3\templib.exp TEINITG.obj : error LNK2019: unresolved external symbol _TEINIT referenced in function _MEXFUNCTION TEINITG.mexw32 : fatal error LNK1120: 1 unresolved externals
C:\PROGRA~2\MATLAB\R2010B~1\BIN\MEX.PL: Error: Link of 'TEINITG.mexw32' failed.
I am running MATLAB R2010b-32bit on windows-64 bit. Might that be the source of problem? I do not know how to deal with this error. Do you have any suggestions that may fix this problem?
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 12월 26일
You have a source file TEINITG.F . Inside that, is the routine named TEINIT with no G ? If so that could be a problem.
Jenny
Jenny 2012년 12월 26일
편집: Jenny 2012년 12월 26일
It was named as TEINIT with no G but after you command I changed it to be TEINITG. However, I am still getting the similar error message. "unresolved external symbol _TEINITG referenced in function _MEXFUNCTION "
Thank you for your suggestion.

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2012년 12월 31일
편집: James Tursa 2012년 12월 31일
You are missing the source code for the TEINIT routine, so there is no object routine TEINIT to link to at link time. I.e., somewhere in your TEINITG.F file you call TEINIT (subroutine or function) but there is no source code for this routine in your TEINITG.F file. Is this in a separate file instead? If so, it must be included on the mex command line, e.g. mex TEINITG.F TEINIT.F all on the same line. Or, if there is an object file or library file that contains this routine, include the name of that object or library file on the mex command line. For a more detailed reply you would need to post your source code.
  댓글 수: 1
Jenny
Jenny 2013년 1월 1일
Problem is solved when we type mex TEINITG.F TEINIT.F all on the same line, instead of TEINITG.F. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2012년 12월 26일
Is TEINITG the name of a defined function? The compiler claimes, that it is not: "unresolved external symbol _TEINITG" means, that there is no such function.
You cannot use the name of the source file to call your function from the inside, because this works from Matlab only. From inside the MEXFUNCTION a recursive call has to call MEXFUNCTION.

카테고리

Help CenterFile Exchange에서 Write 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