From: Fredar M. <mik...@ae...> - 2001-04-20 08:16:05
|
Hi! Perhaps this is an easy question but I'll go through some background inf anyway. I have a problem converting a statically linked program into a dynamically linked program. What I have is a program that consists of three parts: 1: utbep (provides a nice packing to the rest of the program),=20 2: tso.a (contains opengl code, this is the library that I need to convert into a dll) 3: libEp17-nt (contains runtime code such as unpacking and other stuff) These three are depending upon eachother in the following way: ********** *********** * * --------------------> * * * utbep * * ep17-nt * * * <-------------------- * * ********** *********** | | | /\ | | | | | | | | | | ********** | | | * * <-------| | ---------> * tso.a * | * * -------------| ********** What I've come up with after a long time of fiddling is the make script below. It took me a long time to get rid of all undefined symbols but as this makefile looks right now it compiles OK and I get all the files that I need. I told you that the tso.a was the part that I need to turn into a .dll but if you have a look at the makefile below you'll see that I'm trying to make a dll out of libep17-nt to. I do this because utbep consists of both C and ADA code and I didn't want to mess things up trying to make def and exp files based on ADA code. Perhaps this isn't necessary, I don't have the=20 correct info to say wether it is or isn't but the way I did it felt like the way to go.=20 Correct me if I'm wrong. Now, what happens when I run this is that the program tries to load libep17-nt.dll but I get=20 a message that says: The program couldn't be correctly initialized. As far as I know this message has to do with the entrypoint of the dll and I've tried to direct this to=20 these symbols without any luck what so ever. _DllMainCRTStartup@12 _DllMain@12 _TI_DllMain@12 _EP17_DllMain@12 _TI_DllMain@12 and _EP17_DllMain@12 are my own entry points and look like this. ************************************************************************ ************* { MessageBox(0, "START", "ti", MB_OK); switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: MessageBox(0, "DLL_PROCESS_ATTACH", "ti", MB_OK); break; } return TRUE; } ************************************************************************ ************* If someone have an idea about what I can do to solve this I would be the happiest man on earth... Hmmm, well perhaps not the happiest but quite close to it. Thanks... Mikael EP_DLL_OBJS=3D../../utaleprt/bin/libep17-nt.a ep17_dllmain.o TI_DLL_OBJS=3D../../utaoti237/obj/tso.o ../../utaoti237/obj/tso.a ti_dllmain.o . . . ###### Build Starting point=20 dlll: utbep.exe libUtbepImport.a libEp17-nt.dll ###### Main application utbep.exe: glFunctionsDYNAMIC g2_ver.o utbepver.o ti.dll gnatmake -gnatf -g -I$(SOURCEDIR) -I$(IMPORTDIR) -I$(GLIMPORTDIR) -I$(UTAOTIDIR) -L$(IMPORTDIR) -L$(UTALEPRTDIR) utbep \ -largs -lglut32 -lg2comnt -lwsock32 -luser32 -lgdi32 g2_ver.o -L. -lTIImport -lEp17-ntImport \ c:/program/gnat/lib/libopengl32.a c:/program/gnat/lib/libglu32.a glFunctions.o utbepver.o ###### TSO consists of tso.o tso.a and ti_dllmain.o ti.dll: libEp17-ntImport.a tso.def ../../utaoti237/obj/tso.o ../../utaoti237/obj/tso.a ti_dllmain.o @echo . @echo *** Creating ti.dll *** gcc -mdll -g -s $(TI_DLL_OBJS) -o $@ -Wl,--base-file,tso.base,-e,_TI_DllMain@12,-L.,-L$(UTALEPRTDIR),-lep17-n tImport,-lopengl32,-luser32,-lglu32,-lgdi32 dlltool --base-file tso.base --def tso.def --output-exp tso.exp --dllname ti.dll gcc -mdll -g -s -Wl,--base-file,tso.base,tso.exp -o ti.dll $(TI_DLL_OBJS) -Wl,-e,_TI_DllMain@12,-L.,-L$(UTALEPRTDIR),-lep17-ntImport,-lopengl32,-l user32,-lglu32,-lgdi32 dlltool --base-file tso.base --def tso.def --output-exp tso.exp --dllname ti.dll gcc -mdll -g -Wl,tso.exp -o ti.dll $(TI_DLL_OBJS) -Wl,-e,_TI_DllMain@12,-L.,-L$(UTALEPRTDIR),-lep17-ntImport,-lopengl32,-l user32,-lglu32,-lgdi32 dlltool --def tso.def --dllname ti.dll --output-lib libTIImport.a ###### libEp17-nt libEp17-nt.dll: libEp17-ntImport.def $(EP_DLL_OBJS) ep17_dllmain.o @echo . @echo *** Creating libEp17-nt.dll *** gcc -mdll -g -s $(EP_DLL_OBJS) -o $@ -Wl,-e,_EP17_DllMain@12,--base-file,libEp17-nt.base,-L.,-L$(UTALEPRTDIR) ,-lUtbepImport,-lTIImport,-lopengl32,-luser32,-lglu32,-lgdi32 dlltool --base-file libEp17-nt.base --def libEp17-ntImport.def --output-exp libEp17-nt.exp --dllname libEp17-nt.dll gcc -mdll -g -s -Wl,--base-file,libEp17-nt.base,libEp17-nt.exp -o libEp17-nt.dll $(EP_DLL_OBJS) -Wl,-e,_EP17_DllMain@12,-L.,-L$(UTALEPRTDIR),-lUtbepImport,-lTIImport,-l opengl32,-luser32,-lglu32,-lgdi32 dlltool --base-file libEp17-nt.base --def libEp17-ntImport.def --output-exp libEp17-nt.exp --dllname libEp17-nt.dll gcc -mdll -g -Wl,libEp17-nt.exp -o libEp17-nt.dll $(EP_DLL_OBJS) -Wl,-e,_EP17_DllMain@12,-L.,-L$(UTALEPRTDIR),-lUtbepImport,-lTIImport,-l opengl32,-luser32,-lglu32,-lgdi32 dlltool --def libEp17-ntImport.def --dllname libEp17-nt.dll --output-lib libEp17-ntImport.a ###### Create the tso import library libTIImport.a: tso.def $(TI_DLL_OBJS) @echo . @echo - - - Creating libTIImport.a - - - dlltool $(TI_DLL_OBJS) --dllname ti.dll --def tso.def --output-lib libTIImport.a ###### Create the libEp17-nt import library libEp17-ntImport.a: libEp17-ntImport.def @echo . @echo - - - Creating libEp17-ntImport.a - - - dlltool ../../utaleprt/bin/libep17-nt.a --dllname libEp17-nt.dll --def libEp17-ntImport.def --output-lib libEp17-ntImport.a ###### Create the tso def file, sedGetEXPSymbols.scr extracts the symbol names out of the nm listing tso.def: $(TI_DLL_OBJS) @echo . @echo - - - Creating tso.def - - - @echo EXPORTS > tso.def nm ../../utaoti237/obj/tso.o | sed -n -f sedGetEXPSymbols.scr >> tso.def nm ../../utaoti237/obj/tso.a | sed -n -f sedGetEXPSymbols.scr >> tso.def nm ti_dllmain.o | sed -n -f sedGetEXPSymbols.scr >> tso.def ###### Create the libEp17-nt def file, sedGetEXPSymbols.scr extracts the symbol names out of the nm listing libEp17-ntImport.def: $(EP_DLL_OBJS) @echo . @echo - - - Creating libEp17-ntImport.def - - - @echo EXPORTS > libEp17-ntImport.def nm ../../utaleprt/bin/libep17-nt.a | sed -n -f sedGetEXPSymbols.scr | egrep -v -f grepFilterExpSymbols.scr >> libEp17-ntImport.def nm ep17_dllmain.o | sed -n -f sedGetEXPSymbols.scr | egrep -v -f grepFilterExpSymbols.scr >> libEp17-ntImport.def ###### Create the utbep import library libUtbepImport.a: libUtbepImport.def @echo . @echo - - - Creating libUtbepImport.a - - - dlltool utbep.exe --dllname utbep.exe --def libUtbepImport.def --output-lib libUtbepImport.a ###### Create the utbep def file libUtbepImport.def: @echo . @echo - - - Creating libUtbepImport.def - - - @echo EXPORTS > libUtbepImport.def nm utbep.exe | sed -n -f sedGetEXPSymbols.scr | egrep -v -f grepFilterExpSymbols.scr >> libUtbepImport.def ###### Compile ti_dllmain.c ti_dllmain.o: ti_dllmain.c @echo . @echo - - - Creating ti_dllmain.o - - - $(CC) $(CFLAGS) -g -c ti_dllmain.c ###### Compile ep17_dllmain.c ep17_dllmain.o: ep17_dllmain.c @echo . @echo - - - Creating ep17_dllmain.o - - - $(CC) $(CFLAGS) -g -c ep17_dllmain.c |