Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28470 Discussions

Linking to a C library (but has double underscores)

brian
Beginner
743 Views
(cross posted from C++ forum -- sorry if you happen to browse both)

I have run into the infamous double-underscore issue.

I have a library that is written in C and a program that must link with that library written in Fortran 90. The ifort compiler insists on trying to link using single underscore suffixes for the functions it is using from the C library. Originally I used gcc to compile the C library but it produced double underscores. I have tried to compile the C library using icc but I still get double underscores as symbols. Any ideas how I can get ifort to link with double underscores or get icc to not create double underscores?

Thank you,
Brian
0 Kudos
1 Reply
Martyn_C_Intel
Employee
743 Views

I don't see why your C library would produce double underscores unless it was coded that way. It sounds like it may have been designed to link with g77-compiled code, which by default produces symbols with a double underscore.

The Intel Fortran compiler does not have a globaloption to produce symbols with double underscores. (This might mislead users into thinking it was compatible with g77 compiled objects, which it is not, the runtime libraries are very different). You can redefine individual symbols using the attributes directive, e.g.

!DIR$ ATTRIBUTES ALIAS:'newname__' :: oldname

This is discussed in the User's Guide, along with other aspects of mixed language programming and calling conventions. But it might be that a global edit of your C code would be simpler...
Martyn
0 Kudos
Reply