- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I am using Intel C++ compiler and Intel fortran compiler 9. Both are integrated in microsoft visual c++..I am new to mixed level programming...
This is my sample code written in C
#include
void calc_(float *x1, float *y1)
{
float sum;
sum = *x1+*y1;
printf("The sum is %13.5e ",
sum);
return sum;
}
And this is code written in Fortran calling the C function
PROGRAM callc
IMPLICIT NONE
REAL R
REAL :: p1_x, p1_y
EXTERNAL calc
p1_x = 8
p1_y = 5
CALL calc(p1_x,p1_y)
READ(*,*)R
END PROGRAM callc
Now I get the following error when i compile through microsoft visual studio environment
callC error LNK2019: unresolved external symbol _CALC referenced in function _MAIN__
callC fatal error LNK1120: 1 unresolved externals
Please help me to resolve this issue and send me some links where I can read more about mixed level programming from basics...
I am using Intel C++ compiler and Intel fortran compiler 9. Both are integrated in microsoft visual c++..I am new to mixed level programming...
This is my sample code written in C
#include
void calc_(float *x1, float *y1)
{
float sum;
sum = *x1+*y1;
printf("The sum is %13.5e ",
sum);
return sum;
}
And this is code written in Fortran calling the C function
PROGRAM callc
IMPLICIT NONE
REAL R
REAL :: p1_x, p1_y
EXTERNAL calc
p1_x = 8
p1_y = 5
CALL calc(p1_x,p1_y)
READ(*,*)R
END PROGRAM callc
Now I get the following error when i compile through microsoft visual studio environment
callC error LNK2019: unresolved external symbol _CALC referenced in function _MAIN__
callC fatal error LNK1120: 1 unresolved externals
Please help me to resolve this issue and send me some links where I can read more about mixed level programming from basics...
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The examples which come with the compiler should show you some of the basics. Microsoft style defaults are different from linux and cygwin. If you examine the .obj files, using dumpbin /symbols, you would see that the Fortran would call CALC, rather than calc_. Also, if you haven't decided whether you are compiling with C or C++, that would be a useful decision to make. In C++, you would have to add extern "C" to the declaration of CALC. If you want ifort to use the linux style conventions, you need -Qlowercase -us. If you do that, you will not be able to use libraries built for the default convention.
I think I saw a reply from Steve Lionel, but it seems to have been deleted.
I think I saw a reply from Steve Lionel, but it seems to have been deleted.
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