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

64x error LNK 2019

Ralph_Altenfeld
Beginner
489 Views
Hello,

I was previously usnig an old version of Visual C++ and
intel Visual Fortran to compile my application. At this time I
interfaced the C routines so as to use them into the fortran
code using the following procedure:

file.c:
#include <...>
int checkstringtostderr_ ( unsigned int *Length, char *String )
{
....
}

file.f90:
...
INTERFACE
INTEGER FUNCTION checkStringToStdErr ( Length, String )
!DEC$ ATTRIBUTES C, ALIAS:'_checkstringtostderr_' :: checkStringToStdErr
!DEC$ ATTRIBUTES REFERENCE :: Length
!DEC$ ATTRIBUTES REFERENCE :: String
INTEGER, INTENT ( IN ) :: Length
CHARACTER ( LEN = * ), INTENT ( IN ) :: String
END FUNCTION checkStringToStdErr
END INTERFACE
...

Now I am using the Intel64 compiler and I get the following error LNK2019.
I thought that I could resolve this error by setting the calling convention but
I read that for x64 application only the "C, REFERENCE" calling convention
was appliable and it didn't help. Can one help me? Any clues would be very
appreciated.

Cheers

Antoine CARRE



0 Kudos
2 Replies
TimP
Honored Contributor III
489 Views
The evident problem is your use of the leading underscore in the alias.
Now that you are using current compilers, you might consider the Fortran standard way with iso_c_binding.
0 Kudos
Steven_L_Intel1
Employee
489 Views
The problem is caused by the name decoration conventions being different on x64 - no leading underscore.

The simple solution is to remove the leading underscore in the ALIAS attribute and to add the DECORATE attribute in that directive. Tim's suggestion of using BIND(C, NAME=) is another option. Both would allow the same source to work on IA-32 and Intel 64.
0 Kudos
Reply