Dear All,
I want to call c subroutine from fortran, my idea is to create a c project as library file, and add this project into my fortran project then link c part as external lib file, but I failed with the following error:
error LNK2019: unresolved external symbol _F2C_FUNC@32 referenced in function MAIN.
I will attach the code below, hopefully someone can give me some clues to work it out.
program prog
implicit none
external f2c_func
logical*1 bool1
character letter1
integer*4 numint1, numint2
real numfloat1
double precision numdoub1
integer*2 numshor1
call f2c_func(bool1, letter1, numint1, numint2, numfloat1, numdoub1, numshor1)
write( *, "(L2, A2, I5, I5, F6.1, F6.1, I5)") bool1, letter1, numint1, numint2, numfloat1,numdoub1, numshor1
end program prog
[code] #define TRUE 0xff
#define FALSE 0
void f2c_func_( bool1, letter1, numint1, numint2, numfloat1, numdoub1, numshor1)
char *bool1, *letter1;
int *numint1, *numint2;
float *numfloat1;
double *numdoub1;
short *numshor1;
{
*bool1 = TRUE; *letter1 = 'v';
*numint1 = 11; *numint2 = -44;
*numfloat1 = 39.6 ;
*numdoub1 = 39.2;
*numshor1 = 981;
}
Since the c part is library and added into my fortran main program, I link it in the following way:
Property--Linker--input--additional dependencies-- ..\Release\f2c_func.lib.
BTW, I am working on my program by Visual Studio 2008 with a 32 bit windows xp machine.
Any comments and advice will be greatly appreciated,
Zhangping