- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have a small C and Fortran programs.
C-Prog
--------
#include
#include
void CHGSTR(char str1[], char str2[])
{
int i;
char* cstr1 = "STR1ModifiedinC";
char* cstr2 = "String 2 Modified in C";
printf("\nIn C function: strings passed to C - %s, %s\n",str1,str2);
i=0;
while ( ( str1[i++] = *cstr1++ ) != '\0' ); // filling str1
i=0;
while ( ( str2[i++] = *cstr2++ ) != '\0' ); // filling str2
printf("\nIn C function: strings modified in C - %s, %s\n",str1,str2);
}
FORTRAN Prog
----------------
PROGRAM main
CHARACTER*15 string1
CHARACTER*50 string2
string1 = "Fortran String1"
string2 = "Fortran String 2 little lengthy"
write(*,*)"REDDYO - FORTRAN - BEFORE C - ",string1,string2
CALL ChgStr(string1,string2)
write(*,*)"REDDYO - FORTRAN - AFTER C - ",string1,string2
END PROGRAM main
If I compile those two from Intel Fortran Compiler 9.1 prompt I have no issues. where as I would like to work with these two in VS2005 User Interface.
I have VS2005 for C++ and Intel fortran 9.1 for Fortran.
I have created a static library for chgstr.c
I have created a Console Application for Fortran and in project properties -> Linker -> inputs -> Additional Dependencies I have added C Static Libray.
While linking I am finding the following error.
1>------ Build started: Project: fortexe, Configuration: Debug Win32 ------
1>Linking...
1>fmain.obj : error LNK2019: unresolved external symbol _CHGSTR referenced in function _MAIN__
1>Debug/fortexe.exe : fatal error LNK1120: 1 unresolved externals
Please let me know Whether I am doing wrong or is there something else that I have to do or VS2005 IDE wont support linking to Intel Fortran 9.1
Thanks,
Chandra
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
unresolved external symbol _CHGSTR referenced in function _MAIN__
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is one situation where there is value in upgrading to a compiler recent enough to support ISO C interop. Among the possibilities not discussed is that the function name is spelled in lower case in the C code, while, as shown, it is upper case with the Fortran options chosen. dumpbin, or equivalent, may be used to check the .obj files for consistency. Those differences must be reconciled, with too many options available, the only portable one being the ISO C interop.
I used to use either /Qlowercase on the Fortran side, or e.g. -Dfunction=FUNCTION on the C compilation, but that would have been a minority preference.
Another annoyance is that CL supports only C89 without C++ name mangling. ICL doesn't share that limitation. For full interoperability with VC, it may be necessary to use extern "C" even in C code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is one situation where there is value in upgrading to a compiler recent enough to support ISO C interop. Among the possibilities not discussed is that the function name is spelled in lower case in the C code, while, as shown, it is upper case with the Fortran options chosen. dumpbin, or equivalent, may be used to check the .obj files for consistency. Those differences must be reconciled, with too many options available, the only portable one being the ISO C interop.
I used to use either /Qlowercase on the Fortran side, or e.g. -Dfunction=FUNCTION on the C compilation, but that would have been a minority preference.
Another annoyance is that CL supports only C89 without C++ name mangling. ICL doesn't share that limitation. For full interoperability with VC, it may be necessary to use extern "C" even in C code.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page