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

Name mangling problem between ifx compiled code and GNU linker

Paul_Boyle
Beginner
603 Views

Hi,

 

I am new to using Intel's ifx compiler.  I am a scientist who does some programming (mostly C and Python these days).  My fortran knowledge has been, until now, limited to F77.  So, there is a lot for me to learn.  I am doing a port of some Fortran 9x code written by some collaborators to run under Linux.  The most recent versions of their program were developed under Windows.

The Fortran 9x code compiles well with ifx, but when it comes to linking, I get errors which look like this:

ChargeDen.f90:(.text+0x17): undefined reference to `basic_mod_mp_kphase_'
ld: ChargeDen.f90:(.text+0x24): undefined reference to `basic_mod_mp_nphase_'
ld: ChargeDen.f90:(.text+0xf3): undefined reference to `basic_mod_mp_kphase_'

 

There is a module called "Basic_mod" and in the Basic_mod.f90 source file, the corresponding variable declarations look like this:

integer :: NPhase=1,KPhase=1,KPhaseBasic=1,maxNDim,maxNDimI,MaxNComp

 

There seems to be a mismatch in what the ifx compiler produces and the what the GNU linker expects.  My question is how do I get the compiler and linker to agree on name mangling (or lack thereof).  In my ideal world, I am hoping I can use a compiler option (or linker option) to solve the problem.  I haven't been able to find one on my own.

 

Thanks for any guidance.  Apologies in advance if this question is an obvious RTFM or an uber-noobie question.

 

Paul

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
593 Views

It's not an uncommon question. When the source for module basic_mod is compiled, the compiler generates two files: a .mod, which is used by the compiler when you USE the module, and a .o that must be supplied to the linker. Make sure you add the name of the .o file (it will depend on the source file name) to your ld command.

View solution in original post

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
594 Views

It's not an uncommon question. When the source for module basic_mod is compiled, the compiler generates two files: a .mod, which is used by the compiler when you USE the module, and a .o that must be supplied to the linker. Make sure you add the name of the .o file (it will depend on the source file name) to your ld command.

0 Kudos
Paul_Boyle
Beginner
580 Views

Thanks, Steve.  That seems to have done the trick.  I just need to clean up a few more itinerant modules and their .o files.

0 Kudos
Reply