Filter löschen
Filter löschen

mex function : fatal error LNK1120: 1 unresolved externals

14 Ansichten (letzte 30 Tage)
Markela Bargiampa
Markela Bargiampa am 30 Aug. 2023
Bearbeitet: James Tursa am 4 Sep. 2023
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 Kommentare
Markela Bargiampa
Markela Bargiampa am 4 Sep. 2023
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 am 4 Sep. 2023
Bearbeitet: James Tursa am 4 Sep. 2023
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

MYBLOG
MYBLOG am 30 Aug. 2023
Use command
mex myfortranfile.f -compatibleArrayDims -output myfortranfunction

Kategorien

Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by