Linking with object files
Simon Marlow
simonmar@microsoft.com
Wed, 8 Jan 2003 10:04:44 -0000
> I seem to be having some trouble doing this and have a couple=20
> of questions..
>=20
> The first question is how do you use --make option when doing this?
> Section 4.5 of the users guide seems to contradictory to me.
>=20
> It states..
> "The command line must contain one source file or module name"
This is wrong (or at least, out of date). I'll fix it. You can now
specify any number of source files, module names, linkable objects and
libraries on the command line in --make mode or GHCi.
> and later..
> "If the program needs to be linked with additional objects (say, some
> auxilliary C code), these can be specified on the command=20
> line as usual."
>=20
> > ghc Main.hs foo.o
> is OK, but whenever I try this...
>=20
> > ghc --make Main.hs foo.o
> I get the error.. can't find module 'foo.o' <while processing "foo.o">
I think you must be using a version of GHC prior to 5.04.2. This
functionality was fixed in 5.04.2.
> The second question is what object formats does ghc=20
> understand and is the
> object file suffix significant? If I try elf format, this is=20
> accepted without
> complaint but I get a broken executable (though this could=20
> well be because
> my assembler has generated a broken elf file). Using coff=20
> format seems OK.
> The files have a ".o" suffix in both cases.
>=20
> FWIW, I'm using ghc 5.04.2 on Win32 with the nasm assembler.
I'm not sure about this one - any Windows experts out there like to
comment?
My guess is that GHCi should load COFF objects only, but other kinds of
objects might work when using the system linker (i.e. in batch mode).
Cheers,
Simon