- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Now that you are using current compilers, you might consider the Fortran standard way with iso_c_binding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page