필터 지우기
필터 지우기

mex function : fatal error LNK1120: 1 unresolved externals

조회 수: 14 (최근 30일)
Markela Bargiampa
Markela Bargiampa 2023년 8월 30일
편집: James Tursa 2023년 9월 4일
I need to compile a fortran file (myfortranfile.for) using the mex function. As i learned the fortran file must be in .f so i just renamed my file to .f instead of .for. Can someone help? After running the mex function it didn't work , showing the above:
>> matlab_MB_New
Building with 'Intel oneAPI 2023 for Fortran with Microsoft Visual Studio 2022'.
C:\Users\...\ ..\myfortranfile.f(528): remark #8291: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+7'.
102 FORMAT (1X,I3,1X,F9.3,1x,4(E9.3,1X),4(E11.5,1X),3(E11.5,1X))
----------------------------------^
C:\Users\..\myfortranfile.f(528): remark #8291: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+7'.
102 FORMAT (1X,I3,1X,F9.3,1x,4(E9.3,1X),4(E11.5,1X),3(E11.5,1X))
---------------------------------------------^
C:\Users\...\myfortranfile.f(528): remark #8291: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+7'.
102 FORMAT (1X,I3,1X,F9.3,1x,4(E9.3,1X),4(E11.5,1X),3(E11.5,1X))
---------------------------------------------------------^
Error using mex
LINK : error LNK2001: unresolved external symbol MEXFUNCTION
myfortranfile.lib : fatal error LNK1120: 1 unresolved externals
Error in matlab_MB_New (line 5)
mex myfortranfile.f
  댓글 수: 3
Markela Bargiampa
Markela Bargiampa 2023년 9월 4일
no my fortran file doesn't have a subroutine mexfuntion. It's an old fortran code, do I have to add it?
James Tursa
James Tursa 2023년 9월 4일
편집: James Tursa 2023년 9월 4일
Yes, you have to add it. The subroutine mexfunction is the interface between your Fortran code and MATLAB. It would help if you posted the code, or at least described what the code does and what the inputs & outputs are. E.g., why are you trying to connect it with MATLAB?

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

답변 (1개)

MYBLOG
MYBLOG 2023년 8월 30일
Use command
mex myfortranfile.f -compatibleArrayDims -output myfortranfunction

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by