|
From: Daniel G. <ru...@ea...> - 2002-05-08 22:25:47
|
I've been developing C programs for quite some time now, both on Linux and
using lcc-win32 on Windows. When I learned about mingw I decided I'd give it
a shot (I like Makefiles and all that quite a bit better than LCC's build
setup), so as of about a week ago I've been using it and porting a large
project I'm working on to work with it. Right now, it works flawlessly
except for one minor problem.
The project I'm working on now is intended to have a 'plug-in' sort of
interface, basically DLLs that my EXE can load at runtime along with some
functions in the EXE that the DLLs can call back to use the infrastructure
there. Under LCC-Win32, exporting functions from the EXE was not a problem
but I'm having difficulties doing it under mingw.
The functions are declared as __declspec(dllexport) type function(args...) .
Under lcc, this was all I needed to do to build an exe that exported the
functions, however, on mingw it isn't enough.
Compiling without any special options (other than -mwindows), I get an exe
that runs fine but doesn't export any symbols (Verified using dependency
walker, as I'm not yet far enough in the development to actually have dlls
to test with it). Using -shared exports the symbols correctly, but yields
"(program) is not a valid Win32 application." when I try to run it.
I've also tried various other linker options, such
as --export-dynamic/-E, --relocatable/-r and a few other that I don't recall
anymore. These produce working exes, but they don't export anything.
Any ideas what I can do to get an EXE that also exports symbols? I've
included a snapshot of the build below so you can see what all the
compilation looks like
D:\DEV\prj\lragent>make distclean all
del *.o *.bak *.exe *.~*
Could Not Find D:\DEV\prj\lragent\*.o
make -C agent distclean
make[1]: Entering directory `D:/DEV/prj/lragent/agent'
del *.o *.bak *.exe *.res *.ro
make[1]: Leaving directory `D:/DEV/prj/lragent/agent'
make -C agent agent
make[1]: Entering directory `D:/DEV/prj/lragent/agent'
gcc -ggdb3 -Wall -Wundef -Wshadow -Wbad-function-cast -Waggregate-return -
Wnested-externs -ID:\DEV\prj\lragent\agent -DLRAGENT -c -o agent.o
agent.c
gcc -ggdb3 -Wall -Wundef -Wshadow -Wbad-function-cast -Waggregate-return -
Wnested-externs -ID:\DEV\prj\lragent\agent -DLRAGENT -c -o common.o
common.c
gcc -ggdb3 -Wall -Wundef -Wshadow -Wbad-function-cast -Waggregate-return -
Wnested-externs -ID:\DEV\prj\lragent\agent -DLRAGENT -c -o cfg.o cfg.c
(above line repeated for several other C files)
windres -i dialogs.rc -I rc -o dialogs.ro -O coff
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
make[1]: Leaving directory `D:/DEV/prj/lragent/agent'
make -C agent movebinary
make[1]: Entering directory `D:/DEV/prj/lragent/agent'
copy /y lragent.exe D:\DEV\prj\lragent\bin\\lragent.exe
1 file(s) copied.
make[1]: Leaving directory `D:/DEV/prj/lragent/agent'
-- Daniel Grace
|