From: José F. <j_r...@ya...> - 2002-05-09 09:19:13
|
On 2002.05.09 08:41 Luke Dunstan wrote: > > ----- Original Message ----- > From: "Daniel Grace" <ru...@ea...> > To: <min...@li...> > Sent: Thursday, May 09, 2002 8:10 AM > Subject: Re: [Mingw-users] Exporting functions from EXEs > > > > > > From: "José Fonseca" <j_r...@ya...> > > To: <min...@li...> > > -- snip -- > > > > > > Check http://www.mingw.org/docs.shtml for more information about > building > > > DLLs on MinGW. > > > > > -- snip -- > > > Replacing the EXE target command > > > > > > > gcc agent.o common.o cfg.o dlgcfg.o dlgcon.o gw.o lrapi.o > lrapisup.o > > > > notify.o numonly.o tags.o > dialogs.ro -mwindows -ldbuf -lwsock32 -Wl,-E > > > > -o lragent.exe > > > > > > for > > > > > > dllwrap agent.o common.o cfg.o dlgcfg.o dlgcon.o gw.o lrapi.o > > > lrapisup.o > > > notify.o numonly.o tags.o > dialogs.ro -mwindows -ldbuf -lwsock32 -Wl,-E > > > -o lragent.exe > > > > > > or > > > > > > gcc -shared agent.o common.o cfg.o dlgcfg.o dlgcon.o gw.o lrapi.o > > > lrapisup.o > > > notify.o numonly.o tags.o > dialogs.ro -mwindows -ldbuf -lwsock32 -Wl,-E > > > -o lragent.exe > > > > > > should do the trick. > > > > > > José Fonseca > > > > > > > Along with following the instructions at the aforementioned website, > I've > > tried both of those and neither of them work. While they compile and > link > > correctly, the end result isn't executable (it seems to simply be a DLL > with > > an EXE extension) -- I'm left with the same problem I had when I > > used -shared earlier. > > Yes I think you are right that the command Jose gave just creates a DLL > with > a .exe extension. Some reasons why this isn't working may be: > > (1) The linker sets a flag in the executable's header to indicate that it > is > a DLL. > (2) The wrong entry point (DllMain) will be used, and the wrong startup > code > will be linked (dllcrt.o ?) > (3) Other settings like the base address are changed. > Since DLL and EXE have exactly the same format (PE) I thought that this would work. (3) is not important but (1) and (2) might affect the genereation. > I think the reason why compiling normally as an EXE doesn't work is > because > no export section (.edata) will be created by the linker. I haven't tried > this, and I don't have an exact solution but I have a feeling that using > "dlltool --output-exp" to create the exports section (which is just a > special *.o file I think) and linking this with "gcc -o foo.exe *.o > foo.exp" > might work. > If this doesn't work then you'll shurely need to read the dllhelpers (available from Mumit Khan's site) README, which explain the steps made by dllwrap to build a DLL (or alternatively run "dllwrap --dry-run -o foo.exe *.o") - it's basically a series of calls to "gcc" and "dlltool" to generate the exports, and adapt to generate an exe, i.e., remove the "--dll" flag. José Fonseca |