How gfortran build a .lib fortran file?
dealpro
JimChan00@gmail.com
Sun Dec 14 03:08:00 GMT 2008
Steve Kargl wrote:
>
> 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
>
>
thanks for reminding..
I am using mac osx leopard 10.5.5
ranlib mylib.a is not generating mylib.lib or mylib
but follow your hint I tried :
libtool mylib.a -o datamodel.lib
then I can get a datamodel.lib
question is that is this way the .lib is done and OK to be used by C++ or
other program later?
--
View this message in context: http://www.nabble.com/How-gfortran-build-a-.lib-fortran-file--tp20996516p20996707.html
Sent from the gcc - fortran mailing list archive at Nabble.com.
More information about the Fortran
mailing list