How gfortran build a .lib fortran file?
Steve Kargl
sgk@troutmask.apl.washington.edu
Sun Dec 14 02:29:00 GMT 2008
On Sat, Dec 13, 2008 at 06:01:16PM -0800, dealpro wrote:
> Steve Kargl wrote:
> >
> > On Sat, Dec 13, 2008 at 05:49:58PM -0800, dealpro wrote:
> >>
> >> I was using absoft to build datamodel.f in a project to a fortran static
> >> library datamodel.lib which would be used by my C++ code. I recently
> >> switch
> >> to gfortran to compile with a myfile.o is OK but when link the .o to a
> >> .lib
> >> file showing:
> >>
> >> gfortran -static -L/Users/DEVELOP/finclude -o "datamodel.lib"
> >> ./datarmodel.o
> >> collect2: ld returned 1 exit status
> >> ld_classic: can't locate file for: -lcrt0.o
> >>
> >
> > If there are no other object files, then you don't need to
> > create a library. Simply link in your 8.o file.
> >
> > gfortran -c datarmodel.f
> > g++ your_c++_file.cpp datarmodel.o
> >
>
> thank steve, I do have to build a .lib file cause it is in a complex
> directory structure. I have to keep that coz many c/c++ project will use
> this .lib
>
Please, do not top post! Please, use proper Engligh. Many
people subscribed to this list are not native English speakers.
Words like 'coz' can be problematic.
Then you need to make a library with the proper tools. Because
you failed to identify the operating system, I'll assume Linux
in the following.
gfortran -c datarmodel.f
ar -cru mylib.a datarmodel.o
ranlib mylib.a
g++ your_c++_file.cpp -L/path/to/where/you/put/libraries -lmylib
PS: The fortran@gcc.gnu.org mailing list is for the discussion of
development of gfortran. It is not meant for general questions
concerned with how to use gfortran.
--
Steve
More information about the Fortran
mailing list