Non-relocatable DLLs and GCC -shared
Danny Smith
danny_r_smith_2001@yahoo.co.nz
Mon Jul 21 11:57:00 GMT 2003
> From: Pascal Obry <obry at act-europe dot fr>
> --------------------------------------------------------------------------------
>
> I'd like to know if it is possible to build non-relocatable DLLs using GCC's
> -shared option ? As far as I know this option builds relocatable DLLs...
>
> Thanks,
> Pascal.
gcc -mdll -ofoo.dll --Wl,-out-implib,libfoo.a foo.def foo.c
(The foo.def may be omitted if symbols are marked with dllexport in
source. Or you could try -Wl,--export-all)
For mingw32:
-mdll tells driver to pass dllcrt2.o rather than crt2.o as startup
object to ld and to use _DllMainCRTStartup@12 as entry point address.
-shared does this too.
-mdll passes --dll to ld.
-shared passes -shared to ld. This is where the difference is:
--dll only says: 'use default image base for dlls'. It doesn't do any
of the relocatability magic.
-shared says: "build a relocatable dll (or more generally, a shareable
library)" ie, do all the things that dllwrap/dlltool would do
You can (and probably should) override the default image base with ld switch,
--image-base= xxxxxxx.
HTH
Danny
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.
More information about the Gcc-help
mailing list