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

Unresolved external all CAPS

Adrian_F_1
Beginner
932 Views

I am trying to link against a LIB file containing a Fortran subroutine.

A dumpbin /all on the lib shows the Fortran routine as: _ledapm_run2phase

My call in my F90 file is to: call LedaPM_Run2phase(...

which creates an object file containing: _LEDAPM_RUN2PHASE

So I get: error LNK2019: unresolved external symbol _LEDAPM_RUN2PHASE referenced in function _LEDA2P

which is to be expected as in the lib it is all lower case.  How can I get the link working?  Why does the OBJ file capitalize the name?

Using: Intel(R) Composer XE 2013 SP1 Update 2 (package 176)

0 Kudos
3 Replies
mecej4
Honored Contributor III
932 Views

Were the routines in the library compiled using a different compiler? If so, the case of external names is not the only incompatibility that you may have to contend with.

You can control the case of external names through the /names:<keyword> option, where <keyword> is as_is, lowercase, or uppercase. If that does not prove sufficient, you can use the C-interoperability feature of Fortran 200X:

... BIND(C, name='C_Library_Function’) 

or use the older way based on compiler directives (not recommended anymore).

0 Kudos
Adrian_F_1
Beginner
932 Views

The lib is third party, all I am provided with is the LIB and DLL and documentation which shows how to make the call.  There are Fortran and C interfaces (the same name).

I tried adding /names:uppercase to my Fortran project, but I got the same link error.

I also tried adding  BIND(C, NAME="LEDAPM_RUN2PHASE") at the end of my interface / subroutine statement.  But that didn't help either.

0 Kudos
Adrian_F_1
Beginner
932 Views

Sorry the BIND now works if I put :

BIND(C, NAME="LedaPM_Run2phase")

0 Kudos
Reply