symbol name in the .lib file

symbol name in the .lib file

Hi,

I have found that when linking a fortran library in C/C++, the subroutine name has changed to ALL uppercase when compiled by Intel Fortran Compiler.

For example, the subroutine in fortran

 subroutine setulb(n, m, x, l, u, nbd, f, g, factr, pgtol, wa, iwa,
     +                 task, iprint, csave, lsave, isave, dsave)

has changed to SETULB when called in C/C++. 

However, when compiled the fortran code by gfortran, it is setulb_ and the name can be handled by the instructions, such as -fno-underscore, fsource-case-lower.

I would like to know, if there are equivalent instructions in ifort to change the name in the exported lib file, so I can use the same calling for them.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Fortran 2003 added C interoperability features to the language to solve this sort of problem.  Those features are widely supported amongst current Fortran compilers.  You should use those features, rather than relying on compiler specific behaviour - it will make your current and future life much easier.

In Fortran, write a thin wrapper for your procedure that has the BIND(C) attribute and that takes appropriate interoperable arguments.

Intel Fortran does have equivalent options, but I strongly recommend that you take Ian's advice and use the C interoperability features to account for name case and decoration. You could simply add BIND(C) after the close parentheses on the subroutine and this would cause the external name to be lowercased and not have a trailing underscore. I will warn you, though, that use of the interoperability features places some restrictions on what kinds of dummy arguments you can have. In particular, CHARACTER with length other than 1 is not allowed. (You pass strings as an array of single characters.)

Once you do this, you will be independent of implementation specifics for name decoration and case.

Steve - Intel Developer Support

Login to leave a comment.