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 Comment

Are you sure the routine link name is uppercase XDSIFA? You might try lowercase xdsifa instead.

Sign in to comment.

Answers (1)

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

Asked:

on 3 Mar 2011

Community Treasure Hunt

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

Start Hunting!