[Trilinos-Users] Fortran name mangling

Baker, Christopher G. bakercg at ornl.gov
Wed Dec 15 06:15:07 MST 2010

The problem is that the symbol name is being mangled by the C++ compiler. A solution is to define it in an extern block:
$ cat test.cpp
#define Trilinos_Interface trilinos_interface_
extern "C" {
  void Trilinos_Interface() { }
$ icpc -c test.cpp
$ nm test.o | grep trilinos
0000000000000000 T trilinos_interface_

However, I would recommend, if possible, following Scot's advice for standards-compliant and portable solutions to this problem (I'm not sure if you were on the receiving list for this):

On 12/14/10 10:39 AM, "M. Scot Breitenfeld" <brtnfld at uiuc.edu<mailto:brtnfld at uiuc.edu>> wrote:

You can use the BIND statement to avoid the need to guess the naming

    subroutine Trilinos_Interface(...) BIND(c,name='Trilinos_Interface')
end interface

This assumes you have a Fortran 2003 compiler. If this is true then also
make use of the ISO_C_BINDING module as
a portable (and easy way) to interface with C(++).



On 12/14/10 1:34 PM, "Alireza Nejadmalayeri" <Alireza.Nejadmalayeri at Colorado.EDU<mailto:Alireza.Nejadmalayeri at Colorado.EDU>> wrote:

Thanks, Chris. Here is what   "nm Fortran_calls__Trilinos_CC_Interface.o | grep -i trilinos_interface"  returns:
     U trilinos_interface_

And    nm libmyappLib.a | grep -i trilinos_interface  :
     0000000000000050 T _Z19trilinos_interface_PiS_
     0000000000000018 r _Z19trilinos_interface_PiS_$$LSDA

Could you please advise on these.

Thank you,

More information about the Trilinos-Users mailing list