From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cc857abf49a1372e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail Message-ID: <41E7F265.18334E9E@alfred-hilscher.de> Date: Fri, 14 Jan 2005 17:25:09 +0100 From: Alfred Hilscher Organization: none X-Mailer: Mozilla 4.75 [de] (WinNT; U) X-Accept-Language: de MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: DLLs with GNAT? References: <41E1465F.7B44DBC3@alfred-hilscher.de> <1881492.MXiprNB4H5@linux1.krischik.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Date: 14 Jan 2005 17:25:52 MET NNTP-Posting-Host: 3e5b1ac2.newsread2.arcor-online.net X-Trace: DXC=e[LJXmk8Bm?MXCiXZcgNO?Q5U85hF6f;4jW\KbG]kaM8SE6H=g?m\g:6C\=B]C0hV4WEh14DWb8D82cS=0^7`>A?_5\o2 X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:7772 Date: 2005-01-14T17:25:52+01:00 List-Id: 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" -----------------------------------------------------