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,1a80a77402b27e77 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!border-2.ams.xsnews.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!82.197.223.104.MISMATCH!feeder4.cambrium.nl!feed.tweaknews.nl!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Shared library in Ada References: <87od86jc3j.fsf@ludovic-brenta.org> Date: Sat, 19 Apr 2008 15:39:38 +0200 Message-ID: <878wzaj751.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:xhJFs41kV5KABtiVvppHTT9zRVo= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tele2 X-Trace: DXC=jnD>Mc6>A;UK6N>Lad`?AY6`Y6aWje^YZ]^W>8j@H9_Zock\QlbT;:U39eNFmXNNf]:e>`kQhB[cR Xref: g2news1.google.com comp.lang.ada:21004 Date: 2008-04-19T15:39:38+02:00 List-Id: Sebastien writes: >> Yes I'm running Gnat on FreeBSD. >> Thanks about this link, I didn't know. > > I follow the instruction and did the sample thing: [snipped] - Since both your library and your test program are in Ada, you don't need pragma Import or pragma Export. - You do not need to duplicate the mylib.ads file. - If you're going to use project files, you should go all the way and define a library project file for your library, and use that to build the library. The library: package My_Lib is pragma Preelaborate; procedure Print; end My_Lib; with Ada.Text_IO; package body My_Lib is procedure Print is begin Ada.Text_IO.Put_Line ("Hello, World."); end Print; end My_Lib; project My_Lib is for Source_Dirs use ("my_lib"); for Object_Dir use "my_lib.o"; for Library_Name use "mylib"; for Library_Kind use "dynamic"; for Library_Dir use "lib"; for Externally_Built use "false"; end My_Lib; You then build the library like this: gnatmake -Pmy_lib This will produce ./lib/libmylib.so. Then, the client: with My_Lib; procedure Main is begin My_Lib.Print; end Main; with "my_lib"; project Main is for Source_Dirs use ("."); for Main use ("main"); end Main; You would build your client program like this: gnatmake -Pmain which will link main dynamically with lib/libmylib.so. -- Ludovic Brenta.