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,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a80a77402b27e77 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail From: Sebastien Newsgroups: comp.lang.ada Subject: Re: Shared library in Ada Date: Sat, 19 Apr 2008 14:47:43 +0200 Organization: A noiseless patient Spider Message-ID: References: <87od86jc3j.fsf@ludovic-brenta.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX19K5EkdtZ60+P1Qu0/kjPh5vCEzegDsZzGGa/WoM28EZPzn5zkIBXsT7/ZA10YryWZwg/HDc3Ui29lPZANRUOQQ0/9Ki1vOr0jGm1L9IQ1gpApUJUD1S8Qu4kStaEP1Q1c= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Sat, 19 Apr 2008 12:47:39 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX1/sntLy3XKYCvDrLSL3C1jusU9AuNTYxkQ= Cancel-Lock: sha1:6CyG4fF/gHAz8nI4hvN7pQNUjz8= User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) Xref: g2news1.google.com comp.lang.ada:21003 Date: 2008-04-19T14:47:43+02:00 List-Id: > Yes I'm running Gnat on FreeBSD. > Thanks about this link, I didn't know. I follow the instruction and did the sample thing: Lib: :::::::::::::: lib/mylib.adb :::::::::::::: with Ada.Text_IO; use Ada.Text_IO; package body MyLib is procedure Print is begin Put_Line("The lib"); end Print; end MyLib; :::::::::::::: lib/mylib.ads :::::::::::::: package MyLib is procedure Print; pragma Export (Convention => C, Entity => Print, External_Name => "Print"); end MyLib; :::::::::::::: main.adb :::::::::::::: with MyLib; use MyLib; procedure Main is begin Print; end Main; :::::::::::::: mylib.ads :::::::::::::: package MyLib is procedure Print; pragma Import (Convention => C, Entity => Print, External_Name => "Print"); end MyLib; :::::::::::::: main.gpr :::::::::::::: Project Main is for Externally_Built use "true"; for Source_Files use ("main.adb"); pragma Linker_Options ("-lmylib"); end Main; I compile the lib using: gcc-4.1 -g3 -c mylib.adb and link: gcc-4.1 -shared -g3 -o ../libmylib.so mylib.o I compile the main program using gcc-4.1 -g3 -c mylib.ads gcc-4.1 -g3 -c mylib.adb and link: gnatbind -x main.ali gnatlink main.ali -lmylib I got the following error: # ./main raised ADA.IO_EXCEPTIONS.STATUS_ERROR : s-fileio.adb:187 If I don't use shared object I got the program working, what am I missing? Sebastien