- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a solution similar to the sample Fortran_Calls_C.
My c lib compiles ok, but when i try to bulid the fortran program i get a Link error:
1 error LNK2019: unresolved external symbol _get_tflag referenced in _GET...
this is my c function
extern "C" int GET_TFLAG (int TIME_ARRAY[])
{
struct tm tm0;
tm0.tm_sec = TIME_ARRAY[0];
tm0.tm_min = TIME_ARRAY[1];
tm0.tm_hour = TIME_ARRAY[2];
tm0.tm_mday = TIME_ARRAY[3];
tm0.tm_mon = TIME_ARRAY[4];
tm0.tm_year = TIME_ARRAY[5];
tm0.tm_wday = TIME_ARRAY[6];
tm0.tm_yday = TIME_ARRAY[7];
tm0.tm_isdst = -1; //de esta manera fuerzo a que mktime calcule el flag horario
mktime(&tm0);
return tm0.tm_isdst;
}
and this is my interface (inside a fortran subroutine)
INTERFACE
INTEGER FUNCTION GET_TFLAG(TIME_ARRAY)
!DEC$ ATTRIBUTES C :: GET_TFLAG
INTEGER*4 TIME_ARRAY(9)
!DEC$ ATTRIBUTES REFERENCE :: TIME_ARRAY
END FUNCTION GET_TFLAG
Thank you very much
My c lib compiles ok, but when i try to bulid the fortran program i get a Link error:
1 error LNK2019: unresolved external symbol _get_tflag referenced in _GET...
this is my c function
extern "C" int GET_TFLAG (int TIME_ARRAY[])
{
struct tm tm0;
tm0.tm_sec = TIME_ARRAY[0];
tm0.tm_min = TIME_ARRAY[1];
tm0.tm_hour = TIME_ARRAY[2];
tm0.tm_mday = TIME_ARRAY[3];
tm0.tm_mon = TIME_ARRAY[4];
tm0.tm_year = TIME_ARRAY[5];
tm0.tm_wday = TIME_ARRAY[6];
tm0.tm_yday = TIME_ARRAY[7];
tm0.tm_isdst = -1; //de esta manera fuerzo a que mktime calcule el flag horario
mktime(&tm0);
return tm0.tm_isdst;
}
and this is my interface (inside a fortran subroutine)
INTERFACE
INTEGER FUNCTION GET_TFLAG(TIME_ARRAY)
!DEC$ ATTRIBUTES C :: GET_TFLAG
INTEGER*4 TIME_ARRAY(9)
!DEC$ ATTRIBUTES REFERENCE :: TIME_ARRAY
END FUNCTION GET_TFLAG
Thank you very much
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you say ATTRIBUTES C in Fortran, the name is converted to lowercase by default. Your actual C routine is uppercase.
My advice in this case, assuming you are using Intel Visual Fortran, is to remove the ATTRIBUTES lines, both of them. You don't need them. I also note that you declare the array to be 9 elements in the Fortran code but the C code uses only 8.
My advice in this case, assuming you are using Intel Visual Fortran, is to remove the ATTRIBUTES lines, both of them. You don't need them. I also note that you declare the array to be 9 elements in the Fortran code but the C code uses only 8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do a
DUMPBIN /EXPORTS YOURCLIBRARY.LIB
to get the table of exported symbols, then look for the symbol stored for your 'C' Get_Flag routine, then add an ALIAS attribute for the exact symbol name (observing the case-sensitivity of C...) to your Fortran Interface.

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