Call fortran subroutine to C when wirting mex files.

I want to call fortran subroutine in my C code. The fortran subroutine is saved as *.f file and I call the fortran subroutine using
F77_CALL(XDSIFA)(variables...)
and I have the error message:
ex2.c:(.text+0x1852): undefined reference to `XDSIFA_'
Do you have any suggestion to fix this??? Thank you.

1 Kommentar

James Tursa
James Tursa am 3 Mär. 2011
Are you sure the routine link name is uppercase XDSIFA? You might try lowercase xdsifa instead.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kaustubha Govind
Kaustubha Govind am 3 Mär. 2011

0 Stimmen

Use tools like nm (Linux) or dumpbin (Windows) to see how the symbol is defined in your FORTRAN object file. It is likely that your FORTRAN subroutine is called XDSIFA, however, your C compiler is mangling the call XDSIFA to XDSIFA_ (ie. it appends an underscore to the function name). The best solution is to define your FORTRAN subroutine as XDSIFA_ and re-compile the object file, so the symbol names match up.

Kategorien

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

Gefragt:

am 3 Mär. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by