On 03/06/12 14:34, Mcgroder, James wrote:
> $ gfm dates
> + echo Compiling dates.f
> Compiling dates.f
> + gfortran -c -o /usr/local/obj/dates.o dates.f
> + gfortran -o /usr/local/bin/dates.exe /usr/local/obj/dates.o -L /usr/local/lib -l crew
This is the correct way to link gfortran programs.
> However, using ld to create the executable, an unresolved reference results:
> $ ld -o /usr/local/bin/dates.exe /usr/local/obj/dates.o -L /usr/local/lib -lcrew
> -L /mingw/lib/gcc/mingw32/4.6.1 -lgcc -lgfortran
> C:/MinGW/lib/gcc/mingw32/4.6.1/libgcc.a(__main.o):(.text+0x52): undefined reference to `atexit'
You shouldn't do this. Sure, it can be made to work, IFF you take the
trouble to specify ALL of the required libraries, (which you haven't).
Life is too short to waste time figuring that out; just let gfortran
invoke ld for you, and it will take care of it automatically.
> Did attempt to make an import library from msvcrt.dll but the copies
> I have contain no symbols.
The requisite libmsvcrt.a import library is already provided, in the
MinGW.org distribution of gfortran; you may consult the mingwrt source
to see how it is built.
> This was more a point of curiosity than a problem and I'm thinking the
> question belongs on the gfortran mail list anyway...
They too will likely tell you that you should use the gfortran driver to
invoke ld for you, rather than you trying to do it directly; see