Intel vs. GNU compiler when including libraries

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Intel vs. GNU compiler when including libraries

De-Groof, Vincent
Dear All,


I'm trying to switch the used compiler from Intel to GNU for an in-house Fortran code. I've had to make some updates in the code, but have the feeling I'm now getting very close to the end. Unfortunately, 1 problem still persists:

/path/func.o: In function `func_': func.f:(.text+0x683): undefined reference to `start_mesher_'

The interesting thing is, is that this problem does not occur using the Intel compiler. It only arises using gfortran. If I interpret this error message correctly, I has found the external library where this function is stored. However, in this library, it cannot find the function start_mesher_.

Are there things that I need to take special care of that are different when linking to external libraries between Intel's compiler and the GNU compiler?



Best regards,
Vincent
Reply | Threaded
Open this post in threaded view
|

Re: Intel vs. GNU compiler when including libraries

Arjen Markus-4
There is nothing specific about linking against libraries that differs
between the two compilers. The one thing you need to make sure of,
however, is that the libraries are indeed suitable for the compiler.
If they are Fortran libraries, you will have to compile them with the
Fortran compiler you want to use for your programs - different
compilers will refer to different runtime routines and these are
specific for the compiler. For C libraries, this may be relaxed a bit,
but you will still need a C compiler that is compatible to the Fortran
compiler.

In this case, a wild guess is that the library contains a routine
START_MESHER (uppercase, no trailing underscore) or start-mesher (no
trailing underscore). In combination with your observation that Intel
Fortran handles this well, the library is either comiled by Intel
Fortran or was set up for interacting with Intel Fortran. These
compilers use different naming conventions.

Regards,

Arjen

Op do 11 apr. 2019 om 11:21 schreef De-Groof, Vincent
<[hidden email]>:

>
> Dear All,
>
>
> I'm trying to switch the used compiler from Intel to GNU for an in-house Fortran code. I've had to make some updates in the code, but have the feeling I'm now getting very close to the end. Unfortunately, 1 problem still persists:
>
> /path/func.o: In function `func_': func.f:(.text+0x683): undefined reference to `start_mesher_'
>
> The interesting thing is, is that this problem does not occur using the Intel compiler. It only arises using gfortran. If I interpret this error message correctly, I has found the external library where this function is stored. However, in this library, it cannot find the function start_mesher_.
>
> Are there things that I need to take special care of that are different when linking to external libraries between Intel's compiler and the GNU compiler?
>
>
>
> Best regards,
> Vincent
Reply | Threaded
Open this post in threaded view
|

Re: Intel vs. GNU compiler when including libraries

Holcomb, Katherine A (kah3f)
More specifically, there is no standard for name-mangling of Fortran symbols when they are compiled into object or library files. Some compilers use all lower case with no underscores, some use a trailing underscore, I think one (maybe a Cray compiler) used to convert to all uppercase.  Those are the names of the routines that the linker will actually see; it never knows what you name the routine.  An error like you cite usually results from recompiling some but not all source -- which as Arjen said, can result in lots of other incompatibilities.

On 4/11/19, 5:30 AM, "[hidden email] on behalf of Arjen Markus" <[hidden email] on behalf of [hidden email]> wrote:

    There is nothing specific about linking against libraries that differs
    between the two compilers. The one thing you need to make sure of,
    however, is that the libraries are indeed suitable for the compiler.
    If they are Fortran libraries, you will have to compile them with the
    Fortran compiler you want to use for your programs - different
    compilers will refer to different runtime routines and these are
    specific for the compiler. For C libraries, this may be relaxed a bit,
    but you will still need a C compiler that is compatible to the Fortran
    compiler.
   
    In this case, a wild guess is that the library contains a routine
    START_MESHER (uppercase, no trailing underscore) or start-mesher (no
    trailing underscore). In combination with your observation that Intel
    Fortran handles this well, the library is either comiled by Intel
    Fortran or was set up for interacting with Intel Fortran. These
    compilers use different naming conventions.
   
    Regards,
   
    Arjen
   
    Op do 11 apr. 2019 om 11:21 schreef De-Groof, Vincent
    <[hidden email]>:
    >
    > Dear All,
    >
    >
    > I'm trying to switch the used compiler from Intel to GNU for an in-house Fortran code. I've had to make some updates in the code, but have the feeling I'm now getting very close to the end. Unfortunately, 1 problem still persists:
    >
    > /path/func.o: In function `func_': func.f:(.text+0x683): undefined reference to `start_mesher_'
    >
    > The interesting thing is, is that this problem does not occur using the Intel compiler. It only arises using gfortran. If I interpret this error message correctly, I has found the external library where this function is stored. However, in this library, it cannot find the function start_mesher_.
    >
    > Are there things that I need to take special care of that are different when linking to external libraries between Intel's compiler and the GNU compiler?
    >
    >
    >
    > Best regards,
    > Vincent
   

Reply | Threaded
Open this post in threaded view
|

Re: Intel vs. GNU compiler when including libraries

gcc - fortran mailing list
In reply to this post by Arjen Markus-4
On 4/11/2019 5:30 AM, Arjen Markus wrote:

> There is nothing specific about linking against libraries that differs
> between the two compilers. The one thing you need to make sure of,
> however, is that the libraries are indeed suitable for the compiler.
> If they are Fortran libraries, you will have to compile them with the
> Fortran compiler you want to use for your programs - different
> compilers will refer to different runtime routines and these are
> specific for the compiler. For C libraries, this may be relaxed a bit,
> but you will still need a C compiler that is compatible to the Fortran
> compiler.
>
> In this case, a wild guess is that the library contains a routine
> START_MESHER (uppercase, no trailing underscore) or start-mesher (no
> trailing underscore). In combination with your observation that Intel
> Fortran handles this well, the library is either comiled by Intel
> Fortran or was set up for interacting with Intel Fortran. These
> compilers use different naming conventions.
>
> Regards,
>
> Arjen
>
> Op do 11 apr. 2019 om 11:21 schreef De-Groof, Vincent
> <[hidden email]>:
>>
>> Dear All,
>>
>>
>> I'm trying to switch the used compiler from Intel to GNU for an in-house Fortran code. I've had to make some updates in the code, but have the feeling I'm now getting very close to the end. Unfortunately, 1 problem still persists:
>>
>> /path/func.o: In function `func_': func.f:(.text+0x683): undefined reference to `start_mesher_'
>>
>> The interesting thing is, is that this problem does not occur using the Intel compiler. It only arises using gfortran. If I interpret this error message correctly, I has found the external library where this function is stored. However, in this library, it cannot find the function start_mesher_.
>>
>> Are there things that I need to take special care of that are different when linking to external libraries between Intel's compiler and the GNU compiler?
>>
>>
>>
>> Best regards,
>> Vincent
Apparently, you are on a linux-like OS, and the symbols match between
the call and library. Possible problems include link order of static
libraries.  You may display the script passed from ifort to ld by adding
the ifort option -# .  As Arjen pointed out, the run-time libraries of
ifort and gfortran are incompatible, so an object built by ifort is
likely to fail when linked by gfortran.
--
Tim Prince
Reply | Threaded
Open this post in threaded view
|

AW: Intel vs. GNU compiler when including libraries

De-Groof, Vincent
In reply to this post by Holcomb, Katherine A (kah3f)
Hi Katherine and Arjen,


Thanks for the tips and explanation. I had a deeper look at the source code of the library, and made some changes there in the function names. Seems that the intel compiler deals with these differently. Now it works!


Best regards,
Vincent

-----Ursprüngliche Nachricht-----
Von: Holcomb, Katherine A (kah3f) [mailto:[hidden email]]
Gesendet: Donnerstag, 11. April 2019 13:38
An: De-Groof, Vincent
Cc: [hidden email]
Betreff: Re: Intel vs. GNU compiler when including libraries

More specifically, there is no standard for name-mangling of Fortran symbols when they are compiled into object or library files. Some compilers use all lower case with no underscores, some use a trailing underscore, I think one (maybe a Cray compiler) used to convert to all uppercase.  Those are the names of the routines that the linker will actually see; it never knows what you name the routine.  An error like you cite usually results from recompiling some but not all source -- which as Arjen said, can result in lots of other incompatibilities.

On 4/11/19, 5:30 AM, "[hidden email] on behalf of Arjen Markus" <[hidden email] on behalf of [hidden email]> wrote:

    There is nothing specific about linking against libraries that differs
    between the two compilers. The one thing you need to make sure of,
    however, is that the libraries are indeed suitable for the compiler.
    If they are Fortran libraries, you will have to compile them with the
    Fortran compiler you want to use for your programs - different
    compilers will refer to different runtime routines and these are
    specific for the compiler. For C libraries, this may be relaxed a bit,
    but you will still need a C compiler that is compatible to the Fortran
    compiler.
   
    In this case, a wild guess is that the library contains a routine
    START_MESHER (uppercase, no trailing underscore) or start-mesher (no
    trailing underscore). In combination with your observation that Intel
    Fortran handles this well, the library is either comiled by Intel
    Fortran or was set up for interacting with Intel Fortran. These
    compilers use different naming conventions.
   
    Regards,
   
    Arjen
   
    Op do 11 apr. 2019 om 11:21 schreef De-Groof, Vincent
    <[hidden email]>:
    >
    > Dear All,
    >
    >
    > I'm trying to switch the used compiler from Intel to GNU for an in-house Fortran code. I've had to make some updates in the code, but have the feeling I'm now getting very close to the end. Unfortunately, 1 problem still persists:
    >
    > /path/func.o: In function `func_': func.f:(.text+0x683): undefined reference to `start_mesher_'
    >
    > The interesting thing is, is that this problem does not occur using the Intel compiler. It only arises using gfortran. If I interpret this error message correctly, I has found the external library where this function is stored. However, in this library, it cannot find the function start_mesher_.
    >
    > Are there things that I need to take special care of that are different when linking to external libraries between Intel's compiler and the GNU compiler?
    >
    >
    >
    > Best regards,
    > Vincent