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=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLY autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6c0fedd136c7b307 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!peer1.news.newnet.co.uk!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: undefined reference to `adainit' Date: Sun, 17 Feb 2008 22:12:35 +0000 Organization: Pushface Message-ID: References: <47b765d2$1@news.broadpark.no> <47b88598$1@news.broadpark.no> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1203286359 9871 62.49.19.209 (17 Feb 2008 22:12:39 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 17 Feb 2008 22:12:39 +0000 (UTC) Cancel-Lock: sha1:4Ap0IrYoxU2vu52gXsuLjYZtZYw= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (darwin) Xref: g2news1.google.com comp.lang.ada:19841 Date: 2008-02-17T22:12:35+00:00 List-Id: "news.broadpark.no" writes: > "Simon Wright" wrote in message > news:m24pc75v4t.fsf@mac.com... >> Are you trying to make a GNAT project file to (re)build the library, >> or to use the already-built library? The one you post looks like the >> former. >> >> I suspect your problem is the 'for Library_Auto_Init use >> "False";'. Why is this here? > > I have a library with full source code that I will recompile. However, > In the example I provided I have written a small DLL that I'm > compiling. Compiling it thsi way works: > > gnatmake -c api > gnatbind -n api > gnatdll -d api.dll api.ali > > However, using GPS with the settings I provided does not work. Making > the project gives the following output: > > gnatmake -PI:\Temp\ADATest\AdaDLL\api.gpr -d > gnatbind -n -o b~api.adb -Lapi -a api.ali > gcc -c b~api.adb > > building dynamic library for project api > C:\GNAT\2007\bin\gcc.exe -shared -o > i:\temp\adatest\adadll\dll\api.dll > -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/ > i:\temp\adatest\adadll\obj\api.o ... -L.\ > -Li:\temp\adatest\adadll\obj\ > -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/ > -Wl,--stack=0x2000000 > -LC:/GNAT/2007/lib/gcc/pentium-mingw32msv/4.1.3/adalib/ -lgnat-2007 > i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x38): undefined > reference to `adainit' > i:\temp\adatest\adadll\obj\api.o:api.adb:(.text+0x57): undefined > reference to `adafinal' > collect2: ld returned 1 exit status > gnatmake: gcc execution error I'm having trouble with Windows, but the Mac OS X .dylib I'm working on does this: gcc -c b~tash.adb -fPIC -O2 -fPIC -g -g building dynamic library for project build_tash_library /opt/gnat-gpl-2007-static/bin/gcc -dynamiclib -o /Users/simon/sf/tcladashell/lib/libtash.dylib -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -L./ -L/Users/simon/sf/tcladashell/src/.build_lib/ -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -L/usr/lib -ltk8.4 -ltcl8.4 -single_module -L/opt/gnat-gpl-2007-static/lib/gcc/powerpc-apple-darwin8.11.0/4.1.3/adalib/ -lgnarl-2007 -lgnat-2007 -Wl,-flat_namespace -shared-libgcc /Users/simon/sf/tcladashell/src/.build_lib/b~tash.o ... which is quite similar except that (a) it works, (b) you have api.o called up earlier. HOWEVER -- it looks as though your api.adb itself explicitly calls adainit, adafinal -- is that so? It shouldn't. My b~tash.adb defines tashinit and tashfinal, and I believe these are what get called when the dll is loaded/unloaded. adainit/adafinal are what GNAT generates (by default?) when building an executable. I'd expect your b~api.adb to define apiinit, apifinal. I don't know why gnatdll doesn't give the same problem (it's not part of the Mac build). > I have problems seeing whats wrong. I have treid different settings > for Library_Auto_Init, but with the same result. I guess that's not the problem (but I think it should be "True", all the same).