Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

enricoc

macrumors newbie
Original poster
Oct 5, 2006
2
0
Good morning, I have the following problem while interfacing g95 programs with g++:

fortran file: fortran_file.f

subroutine prova(var)
real var
write(*,*) var
end

g95 -c -fno-underscoring fortran_file.f

c++ main file: main.cxx
include <iostream>
using namespace std;
extern "C"{
void prova(float*);
}

main(){
float a = 2.;
prova(&a);
}

g++ main.cpp fortran_file.o

/usr/bin/ld: Undefined symbols:
__g95_filename
__g95_ioparm
__g95_line
__g95_st_write
__g95_st_write_done
__g95_transfer_real
collect2: ld returned 1 exit status

Following the suggestions on g95 web site I used the g95_runtime_start function
void g95_runtime_start(int argc, char *argv[]), but the ld cannot resolve it. Is there one who can give me any suggestions?
 
You need to include the g95 library when linking. For example on my machine I have to include "-L/sw/lib -lg95" to the gcc/g++ command line.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.