Reputation: 935
I have a nice GUI that I've designed using QtCreator that I want to use to call functions from a Fortran source file to do all the backend work. My QtCreator version is 2.7.0 based on Qt 5.0.1 I wrote a simple fortran-90 program in a file named sum.f90 to add two numbers:
integer function addup (a, b)
implicit none
integer a, b
addup = a + b
return
end
Then i added this sum.f90 file to the .pro file in sources like so :
SOURCES += forsum.f90
Then I created a header file fortranlink.h containing the following lines :
extern "C"
{
extern int addup_(int*,int*);
}
Then I included this header file in my main source file "#include fortranlink.h", and called this addup_ function like :
int a=2;
int b=3;
int result=addup_(&a,&b);
After compilation, I get the following errors :
Undefined reference to _gfortran_st_write
Undefined reference to _gfortran_transfer_character_write
Undefined reference to _gfortran_transfer_integer_write
Undefined reference to _gfortran_st_write_done
These errors probably occur because I am not linking in the standard fortran libraries using -lgfortran somewhere. But where do I use it ?
Upvotes: 1
Views: 3441