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.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e273a5259588538c,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: mockturtle Newsgroups: comp.lang.ada Subject: Funny problem with libraries & GNAT (bug?) Date: Tue, 15 Feb 2011 13:40:09 -0800 (PST) Organization: http://groups.google.com Message-ID: Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 93.37.227.198 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297806010 25484 127.0.0.1 (15 Feb 2011 21:40:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 15 Feb 2011 21:40:10 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.37.227.198; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 User-Agent: G2/1.0 Xref: g2news1.google.com comp.lang.ada:17292 Date: 2011-02-15T13:40:09-08:00 List-Id: Dear.all, I was doing some experiments with libraries (using GNAT) and I stumbled on = this strange problem. Let me give you an overview of the problem without th= e complete file set. Since the complete file set is moderately large (~ 15= K), I would post it in a separate message only if necessary. (I am hoping t= hat someone could have some idea even without the whole file set). My experiments are about dynamic loading and tagged object extension. My s= etup is as follows: I have 3 libraries (hashers, dll and the one to be dyna= mically loaded) and one main file. More precisely, # Hasher library * I have a package Hashers that define an abstract object Abstract_Hasher= with a primitive procedure Digest. * I have two children packages Hashers.MD5 and Hashers.SHA1 that define e= xtensions of Abstract_Hasher * Packages Hashers, Hashers.MD5 and Hashers.SHA1 are collected in a libra= ry libhashers.so * The files are in subdirectory Hashers/ # DLL library * I have a package DLL that define a layer over the dlopen-type functions= (to dynamically load libraries at run-time). * Package DLL is in a library of its own (libdll.so) * The files are in subdirectory DLL/ # To be loaded * I have a third children package Hashers.Strange in a library libstrange= .so of its own. This library is to be loaded at runtime # Main program * The main program with-s Hashers and DLL and calls DLL.Open to load libs= trange The project files are as follows =20 -- Hashers/hashers.gpr=20 project Hashers is for Object_Dir use "bin"; for Library_Name use "hasher"; for Library_Dir use "lib"; for Library_Kind use "dynamic"; for Library_Version use "1.0"; for Library_Interface use ("Hashers", "Hashers.MD5", "Hashers.SHA1"); end Hashers; -- DLL/dll.gpr project DLL is for Object_Dir use "bin"; for Library_Name use "dll"; for Library_Dir use "lib"; for Library_Kind use "dynamic"; for Library_Version use "1.0"; end DLL; -- test_dll_bad with "DLL/dll"; with "Hasher/hashers"; project Test_dll_bad is for Main use ("main.adb"); for Object_Dir use "bin"; package Binder is for Default_Switches ("ada") use ("-largs", "-ldl"); end Binder; end Test_dll_bad; -- test_hash_bad with "Hasher/hashers"; with "DLL/dll"; project Test_hash_bad is for Main use ("main.adb"); for Object_Dir use "bin"; package Binder is for Default_Switches ("ada") use ("-largs", "-ldl"); end Binder; end Test_hash_bad; Note that the only difference between test_dll_bad.gpr and test_hash_bad.gp= r is the different order of the with's. If I try to do gnatmake -Ptest_dll_bad I get gnatlink /home/bernardi/Ada/prove/DLL-test/bin/main.ali -shared-libgcc -l= dl=20 -L/home/bernardi/Ada/prove/DLL-test/Hasher/lib/ -lhasher=20 -L/home/bernardi/Ada/prove/DLL-test/DLL/lib/ -ldll=20 -Wl,-rpath,/home/bernardi/Ada/prove/DLL-test/Hasher/lib/:/home/bernardi/A= da/prove/DLL-test/DLL/lib/:/home/bernardi/gnat/lib/gcc/i686-pc-linux-gnu/4.= 3.4/adalib/ -o /home/bernardi/Ada/prove/DLL-test/bin/main b~main.o: In function `adainit': b~main.adb:(.text+0x3a9): undefined reference to `dll_E' b~main.adb:(.text+0x3b5): undefined reference to `dll___elabs' b~main.adb:(.text+0x3bb): undefined reference to `dll_E' /home/bernardi/Ada/prove/DLL-test/bin/main.o: In function `_ada_main': main.adb:(.text+0x58): undefined reference to `dll__open' that is, the linker does not find the functions in libdll.so, despite the f= act that it links it (see the -ldll) and the fact that the functions are th= ere, for example, nm DLL/lib/libdll.so | grep dll__open gives 00000946 T dll__open 00000b76 t dll__open__B_1__map_init_function.1448 If instead I use test_hash_bad (remember: with the with's exchanged), that = is gnatmake -Ptest_hash_bad then libhasher.so has problems gnatlink /home/bernardi/Ada/prove/DLL-test/bin/main.ali -shared-libgcc = -ldl -L/home/bernardi/Ada/prove/DLL-test/DLL/lib/ -ldll -L/home/bernardi/Ad= a/prove/DLL-test/Hasher/lib/ -lhasher -Wl,-rpath,/home/bernardi/Ada/prove/D= LL-test/DLL/lib/:/home/bernardi/Ada/prove/DLL-test/Hasher/lib/:/home/bernar= di/gnat/lib/gcc/i686-pc-linux-gnu/4.3.4/adalib/ -o /home/bernardi/Ada/prove= /DLL-test/bin/main /home/bernardi/Ada/prove/DLL-test/bin/main.o: In function `_ada_main': main.adb:(.text+0x366): undefined reference to `hashers__get_hasher' Now the linker does not find hashers__get_hasher, despite the -lhasher abov= e and the fact that hashers__get_hasher is there=20 nm Hasher/lib/libhasher.so | grep hashers__get_hasher 0000e1e2 T hashers__get_hasher 0000eb10 t hashers__get_hasher___clean.6583 Note that in both cases, the linker does not see the functions of the first= with-ed library. Any ideas?