Call fortran subroutine to C when wirting mex files.

1 view (last 30 days)
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 Comment
James Tursa
James Tursa on 3 Mar 2011
Are you sure the routine link name is uppercase XDSIFA? You might try lowercase xdsifa instead.

Sign in to comment.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 3 Mar 2011
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.

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!