* DLLs with GNAT? @ 2005-01-09 14:57 Alfred Hilscher 2005-01-12 21:51 ` Bernd Specht 2005-01-14 8:57 ` Martin Krischik 0 siblings, 2 replies; 6+ messages in thread From: Alfred Hilscher @ 2005-01-09 14:57 UTC (permalink / raw) Hi, I try to write a DLL with GNAT but I've got some problem. I've done the example from the GNAT maual and I succeed to built and to call the DLL. Then I've tried to do some initialisation by adding the DllMain function. gnatdll shows a warning that DllMain is linked to DllMain@12, but windows seems _not_ to call the DllMain when loaing my dll. What's wrong? Please, can someone help me? Thanks, Alfred ----------------------------------------------------- To send me mail, please replace "Spam" by "Jedermann" ----------------------------------------------------- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DLLs with GNAT? 2005-01-09 14:57 DLLs with GNAT? Alfred Hilscher @ 2005-01-12 21:51 ` Bernd Specht 2005-01-13 0:20 ` Jeff C 2005-01-14 8:57 ` Martin Krischik 1 sibling, 1 reply; 6+ messages in thread From: Bernd Specht @ 2005-01-12 21:51 UTC (permalink / raw) Alfred Hilscher <SPAM@alfred-hilscher.de> wrote in news:41E1465F.7B44DBC3 @alfred-hilscher.de: > Hi, > > I try to write a DLL with GNAT but I've got some problem. > > I've done the example from the GNAT maual and I succeed to built and to > call the DLL. Then I've tried to do some initialisation by adding the > DllMain function. gnatdll shows a warning that DllMain is linked to > DllMain@12, but windows seems _not_ to call the DllMain when loaing my > dll. > > What's wrong? Please, can someone help me? > > Thanks, > Alfred > > ----------------------------------------------------- > To send me mail, please replace "Spam" by "Jedermann" > ----------------------------------------------------- > Hi Alfred, did you already get an answer? No? So do you believe me *now* that Ada is *not* useable for professional work? If you would use C then you could have finished your work already, instead of waiting for someone (who will never come) to help you with your problems. Maybe we should meet again and go for a beer. I will show you my C- environment :-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DLLs with GNAT? 2005-01-12 21:51 ` Bernd Specht @ 2005-01-13 0:20 ` Jeff C 0 siblings, 0 replies; 6+ messages in thread From: Jeff C @ 2005-01-13 0:20 UTC (permalink / raw) "Bernd Specht" <Bernd.Specht@gmx.com> wrote in message news:Xns95DCE8981FD5BBerndSpechgmxcom@151.189.20.10... > Alfred Hilscher <SPAM@alfred-hilscher.de> wrote in news:41E1465F.7B44DBC3 > @alfred-hilscher.de: > >> Hi, >> >> I try to write a DLL with GNAT but I've got some problem. >> >> I've done the example from the GNAT maual and I succeed to built and to >> call the DLL. Then I've tried to do some initialisation by adding the >> DllMain function. gnatdll shows a warning that DllMain is linked to >> DllMain@12, but windows seems _not_ to call the DllMain when loaing my >> dll. >> >> What's wrong? Please, can someone help me? >> >> Thanks, >> Alfred >> >> ----------------------------------------------------- >> To send me mail, please replace "Spam" by "Jedermann" >> ----------------------------------------------------- >> > > Hi Alfred, > > did you already get an answer? No? So do you believe me *now* that Ada is > *not* useable for professional work? > If you would use C then you could have finished your work already, instead > of waiting for someone (who will never come) to help you with your > problems. > Maybe we should meet again and go for a beer. I will show you my C- > environment :-) > Please keep the lang flame wars in private e-mail. We all have horror stories for every language/environment. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DLLs with GNAT? 2005-01-09 14:57 DLLs with GNAT? Alfred Hilscher 2005-01-12 21:51 ` Bernd Specht @ 2005-01-14 8:57 ` Martin Krischik 2005-01-14 16:25 ` Alfred Hilscher 1 sibling, 1 reply; 6+ messages in thread From: Martin Krischik @ 2005-01-14 8:57 UTC (permalink / raw) Alfred Hilscher wrote: > Hi, > > I try to write a DLL with GNAT but I've got some problem. Which Version of GNAT? Newer Versions of GNAT have improved Windows-DLL support. Improved means easier here. I have created working DLLs with GNAT 3.15. Once you did everything in the instructions it works without problems. > I've done the example from the GNAT maual and I succeed to built and to > call the DLL. Then I've tried to do some initialisation by adding the > DllMain function. gnatdll shows a warning that DllMain is linked to > DllMain@12, but windows seems _not_ to call the DllMain when loaing my > dll. Well I done that and it does work. However I stopped unsing DllMain - not because of problems but for better Linux portability. > What's wrong? Please, can someone help me? I haven't got enough informations to help you. Did you use Makefiles or Projectfiles? GNAT Version etc. pp. IF you know how to use cvs download: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/adacl/CUnicode and look how I did it. If not you can browse online: http://cvs.sourceforge.net/viewcvs.py/adacl/CUnicode With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DLLs with GNAT? 2005-01-14 8:57 ` Martin Krischik @ 2005-01-14 16:25 ` Alfred Hilscher 2005-01-14 16:51 ` Martin Krischik 0 siblings, 1 reply; 6+ messages in thread From: Alfred Hilscher @ 2005-01-14 16:25 UTC (permalink / raw) Martin Krischik schrieb: > > Alfred Hilscher wrote: > > > Hi, > > > > I try to write a DLL with GNAT but I've got some problem. > > Which Version of GNAT? Newer Versions of GNAT have improved Windows-DLL > support. Improved means easier here. I have created working DLLs with GNAT > 3.15. Once you did everything in the instructions it works without > problems. I work with GNAT 3.15p. First I tried the example from the GNAT users guide. I followed every step, built all files (.def, .ads, ...) then built the dll with "gnatdll -d api.dll api.ali". Then I did the steps described in "25.8.7.2 gnatdll behind the scenes". Both produced a dll that I can access. But, in "25.8.3 Ada dlls and elaboration" it is mentioned, that one has to call adainit, and that this could be done in DllMain. So I extended the file from the example by adding a "function DllMain (...) return ..", which I want to call the adainit. And I've added the DllMain to the export list. But it seems that it is not called. > > I've done the example from the GNAT maual and I succeed to built and to > > call the DLL. Then I've tried to do some initialisation by adding the > > DllMain function. gnatdll shows a warning that DllMain is linked to > > DllMain@12, but windows seems _not_ to call the DllMain when loaing my > > dll. > > Well I done that and it does work. However I stopped unsing DllMain - not > because of problems but for better Linux portability. > > > What's wrong? Please, can someone help me? > > I haven't got enough informations to help you. Did you use Makefiles or > Projectfiles? GNAT Version etc. pp. I wrote the commands as in the docu. 1. Trial with Interfaces.C; use Interfaces; package API is function Factorial (Val : C.int) return C.int; procedure Init_API; procedure Finish_API; private pragma Export (C, Init_API); pragma Export (C, Finish_API); pragma Export (C, Factorial); end API; gnatdll -e api.def -d api.dll api.ali -largs -s 2. Trial with Interfaces.C; use Interfaces; with Win32; with Win32.Winnt; package API is function Factorial (Val : C.int) return C.int; procedure Init_API; procedure Finish_API; function DLLMain (hInstDLL : Win32.Winnt.HANDLE; dwReason : Win32.DWORD; lpvReserved : Win32.LPVOID) return Win32.BOOL; private pragma Export (C, Init_API); pragma Export (C, Finish_API); pragma Export (C, Factorial); pragma Export (C, DllMain); end API; gnatdll -e api.def -d api.dll api.ali -largs -s 3. Trial gnatbind -n api gnatlink api -o api.jnk -mdll -Wl,--base-file,api.base dlltool --dllname api.dll --def api.def --base-file api.base --output-exp api.exp gnatbind -n api gnatlink api -o api.jnk api.exp -mdll -Wl,--base-file,api.base dlltool --dllname api.dll --def api.def --base-file api.base --output-exp api.exp --output-lib libAPI.a gnatbind -n api gnatlink api api.exp -o api.dll -mdll > IF you know how to use cvs download: > > :pserver:anonymous@cvs.sourceforge.net:/cvsroot/adacl/CUnicode > > and look how I did it. If not you can browse online: I know only the name, not how to use it. > http://cvs.sourceforge.net/viewcvs.py/adacl/CUnicode I will check it. Thanks. > With Regards > > Martin > -- > mailto://krischik@users.sourceforge.net > http://www.ada.krischik.com Regards, Alfred ----------------------------------------------------- To send me mail, please replace "Spam" by "Jedermann" ----------------------------------------------------- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DLLs with GNAT? 2005-01-14 16:25 ` Alfred Hilscher @ 2005-01-14 16:51 ` Martin Krischik 0 siblings, 0 replies; 6+ messages in thread From: Martin Krischik @ 2005-01-14 16:51 UTC (permalink / raw) Alfred Hilscher wrote: > function DLLMain (hInstDLL : Win32.Winnt.HANDLE; > dwReason : Win32.DWORD; > lpvReserved : Win32.LPVOID) return Win32.BOOL; > private > pragma Export (C, Init_API); > pragma Export (C, Finish_API); > pragma Export (C, Factorial); > pragma Export (C, DllMain); > end API; Having seen your source I can give you a more excact URL: http://cvs.sourceforge.net/viewcvs.py/adacl/CUnicode/Include/NT/ada_dll.ads?view=markup look for the pragma export of DllMain! And for good friends of yours advocating C language: if you acidently used __cdecl on DllMain it would not have worked in C either. Or if __cdecl is default and you forget to use __stdcall. And of corse, same if you forget to use either export "C" or __stdcall when using C++. A little mistake which can happen to anybody in any programming language. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-01-14 16:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-01-09 14:57 DLLs with GNAT? Alfred Hilscher 2005-01-12 21:51 ` Bernd Specht 2005-01-13 0:20 ` Jeff C 2005-01-14 8:57 ` Martin Krischik 2005-01-14 16:25 ` Alfred Hilscher 2005-01-14 16:51 ` Martin Krischik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox