Effacer les filtres
Effacer les filtres

mex function : fatal error LNK1120: 1 unresolved externals

14 vues (au cours des 30 derniers jours)
Markela Bargiampa
Markela Bargiampa le 30 Août 2023
Modifié(e) : James Tursa le 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 commentaires
Markela Bargiampa
Markela Bargiampa le 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 le 4 Sep 2023
Modifié(e) : James Tursa le 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?

Connectez-vous pour commenter.

Réponses (1)

MYBLOG
MYBLOG le 30 Août 2023
Use command
mex myfortranfile.f -compatibleArrayDims -output myfortranfunction

Catégories

En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by