From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Relocatable lib calling external C libs: undefined references Date: Thu, 13 Aug 2020 14:31:22 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 7nk0b43GqgQBWPATejSmcQ47ZzJ7RWZQeR3/3nE+yi/1pa+aas Cancel-Lock: sha1:48zIhZKy2gmC0wEN1CNtSOUUdY8= X-Mozilla-News-Host: news://News.Individual.DE:119 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59713 List-Id: Trying for several days now, I don't get my project to link when I use relocatable libraries, and only then. First, I made a thin binding to GSL (GNU Scientific Library). The .ads files were generated with "g++ -c -fdump-ada-spec ...", with some corrections. The result used here is gsl_integration_h.ads. From that, I made a thick binding, called Integration. And finally, I wrote a test program Test_Integration which imports a test function from package Test_Integ_Aux. The subprogram call graph is Test_Integration / \ thick --> Integration.Integration_QNG Test_Integ_Aux.Circle | gsl_integration_h.gsl_integration_qng <-- thin The project files are: -- gsl_thin.gpr -- library project GSL_Thin is for Source_Dirs use ("."); for Library_Dir use "lib"; for Object_Dir use "obj"; for Library_Name use "gsl_thin"; for Library_Kind use "relocatable"; for Externally_Built use "false"; package Compiler is for Default_Switches ("ada") use ("-g"); end Compiler; package Linker is for Linker_Options use ("-L/usr/lib/x86_64-linux-gnu", "-lgsl", "-lgslcblas"); end Linker; end GSL_Thin; -- gsl.gpr -- with "Thin/gsl_thin"; library project GSL is for Source_Dirs use ("."); for Object_Dir use "obj"; for Library_Dir use "lib"; for Library_Name use "gsl"; for Library_Kind use "relocatable"; for Library_Interface use ("Integration"); for Externally_Built use "false"; package Compiler is for Default_Switches ("ada") use ("-g"); end Compiler; package Linker is for Linker_Options use ("-g"); end Linker; end GSL; -- test_integration.gpr -- with "../Library/gsl"; project Test_Integration is for Source_Dirs use ("."); for Object_Dir use "obj"; for Exec_Dir use "."; for Main use ("test_integration.adb"); package Compiler is for Default_Switches ("ada") use ("-g"); end Compiler; package Linker is for Linker_Options use ("-g"); end Linker; end Test_Integration; When I call gprbuild with the last one, I get Compile [Ada] test_integration.adb [Ada] gsl_integration_h.ads [Ada] gsl_math_h.ads [Ada] integration.adb [Ada] test_integ_aux.adb Build Libraries [gprlib] gsl_thin.lexch [gprlib] gsl.lexch [link library] libgsl_thin.so [bind SAL] gsl [Ada] b__gsl.adb [link library] libgsl.so Bind [gprbind] test_integration.bexch [Ada] test_integration.ali Link [link] test_integration.adb /opt/GNAT/2020/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: /home/frank/Temp/Test/Library/lib//libgsl.so: undefined reference to `gsl_integration_qng' collect2: error: ld returned 1 exit status gprbuild: link of test_integration.adb failed gprbuild: failed command was: /opt/GNAT/2020/bin/gcc test_integration.o b__test_integration.o /home/frank/Temp/Test/Test/obj/test_integ_aux.o -L/home/frank/Temp/Test/Library/lib/ -lgsl -L/home/frank/Temp/Test/Library/Thin/lib/ -lgsl_thin -g -L/usr/lib/x86_64-linux-gnu -lgsl -lgslcblas -L/home/frank/Temp/Test/Test/obj/ -L/home/frank/Temp/Test/Test/obj/ -L/home/frank/Temp/Test/Library/lib/ -L/home/frank/Temp/Test/Library/Thin/lib/ -L/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/adalib/ -shared-libgcc -lgnat-2020 -ldl -Wl,-rpath-link,/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1//adalib -Wl,-z,origin,-rpath,$ORIGIN/..//Library/lib:$ORIGIN/..//Library/Thin/lib:/usr/lib/x86_64-linux-gnu:$ORIGIN//obj:/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/adalib:/opt/GNAT/2020/lib64:/opt/GNAT/2020/lib -o /home/frank/Temp/Test/Test//test_integration When I look with nm into libgsl.so I see indeed gsl_integration_qng undefined: U gsl_integration_qng and a little below: 0000000000002090 T integration__integration_qng When compiling the libraries as static, the program works, but whatever project variation I try with relocatable ones, I get this linking error. I even made some simpler examples with relocatable libraries and without external C libraries, with corresponding project files, and they all work. So I don't know what to try else. -- Frank Hrebabetzky, Kronach +49 / 9261 / 950 0565