This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Compiling C/C++/FORTRAN project


Hi all,

My project makes use of C/C++/FORTRAN subroutines. This is how the project
is structured:
My main() is in FORTRAN. (say main.f)
main.f call a set of C subroutines (blah1.c and blah2.c) and
FORTRAN(prog1.f, prog2.f) subroutines. The C subroutines in turn call the
C++ subroutines (test1.cpp, test2.cpp) 
Also, these subroutines need to linked to libraries when creating the
executable.
So, for compiling the entire project (to create the object files) what I did
was I used g++ compiler to compile both the C and C++ subroutines and use
g77 for the FORTRAN codes.

g77 -c *.f
g++ -c *.c
g++ -c *.cpp

My question now is when I create the executable, what compiler should I use
(g77/g++):
When I try using the g77
g77 main.f *.o -o exec <libraries>
I get lot of errors because the libraries dont get linkes
When I use g++, it says the following 

main.o: In function `funcc_':
main.f:(.text+0x33c): undefined reference to `blah1_'
main.o: In function `grad_':
main.f:(.text+0x372): undefined reference to `blah2_'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libf2c.so: undefined
reference to `MAIN__'

Can someone get me out of this plz..

Thanks!!



-- 
View this message in context: http://www.nabble.com/Compiling-C-C%2B%2B-FORTRAN-project-tp20162079p20162079.html
Sent from the gcc - fortran mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]