Azzera filtri
Azzera filtri

mex function : fatal error LNK1120: 1 unresolved externals

14 visualizzazioni (ultimi 30 giorni)
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 Commenti
Markela Bargiampa
Markela Bargiampa il 4 Set 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 il 4 Set 2023
Modificato: James Tursa il 4 Set 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?

Accedi per commentare.

Risposte (1)

MYBLOG
MYBLOG il 30 Ago 2023
Use command
mex myfortranfile.f -compatibleArrayDims -output myfortranfunction

Categorie

Scopri di più su Fortran with MATLAB in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by