Ya znaju kak iz C, no v C++ etot sposob ne prokatybaet.
c2f77.cpp:
extern "C++"
{
extern void showhie_(/*char* hello,*/int* length,double* e);
}
int main ( )
{
int i;
char hello[32];
//showhie(char *fr,int x,float f);
int length=sizeof(hello);
length=56;
double e = 21.7;
strcpy(hello,"Hello Fortran from C");
for (i=strlen(hello);i<length; i++)
hello[i]=' ';
showhie_(/*hello,*/&length,&e);
//Showhie(hello,length,e)
return 0;
}
showhie.f: SUBROUTINE SHOWHIE(LENGTH,E)
c CHARACTER*(*) HELLO
INTEGER LENGTH
REAL E
c
WRITE(*,100),LENGTH,E
100 FORMAT(3X,A,2X,I3,4X,F6.4)
RETURN
END SUBROUTINE SHOWHIE
ffromc.bat:
f77 -c showhie.f -o showhie.o
g++ -c c2f77.cpp -o c2f77.o
g++ c2f77.o showhie.o -lg2c -lm -o c2f77
./ffromc.bat vydaet:
c2f77.o(.text+0x6c): In function `main':
: undefined reference to `showhie_(int *, double *)'
collect2: ld returned 1 exit status
Chto eto takoe, s chem svyazano? Kak ispravit'?
Исправлено: Zar, 16:43 3-09-2004
ruslandh
03-09-2004, 21:12
extern "C"
{
extern void showhie_(/*char* hello,*/int* length,double* e);
}
]
А если так ?
Ur-a-a-a-a-a-a-a!!!
Zarabotalo-o!
:rotate:
Большое спасибо, я уж и не надеялся узнать.
Исправлено: Prisoner, 3:05 6-09-2004
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.