How gfortran build a .lib fortran file?

Steve Kargl sgk@troutmask.apl.washington.edu
Sun Dec 14 02:02:00 GMT 2008


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

-- 
Steve



More information about the Fortran mailing list