Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Kunal_Rao
Novice
41 Views

Fortran and C name mangling issue with intel compilers

Hi
I am having a huge application with lots of Fortran files and C files. I am using Intel Compiler Suite Professional Edition for Windows and working in the cygwin environment.
icl is:
------
Intel C++ Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100806 Package ID: w_cproc_p_11.1.067
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
------
ifort is:
------
Intel Visual Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100806 Package ID: w_cprof_p_11.1.067
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
------
The C routines are being called from fortran files.
After compiling with intel compilers, Fortran object files have symbols without the trailing underscore while the C files have the object files with the symbols with a trailing underscore.
e.g. C object file has dummy_symbol_
Fortran object file has dummy_symbol
Due to this I am getting unresolved external symbol errors.
This works with other compilers, but with intel compilers, this C and Fortran interoperability issue I am facing.Is there some easy way to fix this, without going into the code and making changes for each routine ?
May be by adding some flag while compiling C/Fortran files or having some environment variable set which can take care of that trailing underscore or some other alternative.. ?
I was looking in the user guide but could not find the reqd. information properly. Can you please let me know how do I resolve this issue ?
Thanks & Regards,
Kunal
0 Kudos
2 Replies
Milind_Kulkarni__Int
New Contributor II
41 Views

I think from Fortran side, you can decorate names using something like:--

1.

[bash]interface
subroutine dummy_symbol(a,b)
!DEC$ ATTRIBUTES DECORATE, ALIAS:"dummy_symbol_"::dummy_symbol
real a, b
end subroutine
end interface

[/bash]

2. Alternatively, try this after removing the DEC, ATTRIBUTES line
subroutine dummy_symbol(a,b) BIND(C,NAME='dummy_symbol_') ..

If you want to do that with compiler flags, I thought there is an option to add underscore:--
-assume underscore ..

Only, it may add underscore to every other routine which may be unwanted.

Try all these if it works..

Kunal_Rao
Novice
41 Views

okay, Thanks !! I got it !!
Regards,
Kunal