Re: Need Help in compiling
sajid hameed <sajidhh@yahoo.ca> writes:
> 1. (*) text/plain ( ) text/html
(Please post to the mailing list in plain text only.)
> i have started using unix recently i have an problem using fortran
> i have write a program in fortran namely test.f that uses a subroutine
> displaymessage.f and this subroutine uses another subroutine display.f
> i compiled all of them in single library say libt.a when a make an
> executable file of it the error is
> No Main Fortran Program to execute
What commands, exactly, are you using to do this? This is a little
unusual way to compile programs. In C, at least, I happen to know
that putting main() in a library would work. Playing around with g77,
though, it looks like this fails. That is, if main.f is
C main.f: pull some FORTRAN code...
PROGRAM MAIN
CALL PRINTMESSAGE
END
and printmessage.f is
C printmessage.f: define the PRINTMESSAGE subroutine
SUBROUTINE PRINTMESSAGE
V = 17
WRITE(*,*) V
END
I can use 'g77 -c main.f' to get main.o, 'g77 -c printmessage.f' to
get printmessage.o, and 'g77 main.o printmessage.o' to get a binary
(a.out). I can use 'ar cru libpm.a printmessage.o' to get a library
containing the PRINTMESSAGE subroutine, then use 'g77 -L. main.o -lpm'
to get the same a.out binary. But putting main.o in a libary doesn't
work at all.
I suspect that some of this is the behavior of the system linker with
respect to libraries. But really, the best answer is "don't do that":
if it doesn't work on Linux, it seems unlikely to go on any other
Unix-like system either.
--
David Maze dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: