From: Sébastien <seb.morand@gmail.com>
Subject: Re: Shared library in Ada
Date: Mon, 21 Apr 2008 10:09:19 +0000
Date: 2008-04-21T10:09:19+00:00 [thread overview]
Message-ID: <fuhp0t$os4$1@registered.motzarella.org> (raw)
In-Reply-To: <878wzaj751.fsf@ludovic-brenta.org>
Thanks for you help, it's working fine.
Sebastien
> Sebastien <seb.morand@gmail.com> 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.
>
> Sebastien <seb.morand@gmail.com> 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.
>
prev parent reply other threads:[~2008-04-21 10:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-19 11:27 Shared library in Ada Sebastien
2008-04-19 11:41 ` Georg Bauhaus
2008-04-19 11:51 ` Sebastien
2008-04-19 15:31 ` Robert A Duff
2008-04-19 11:52 ` Ludovic Brenta
2008-04-19 11:55 ` Sebastien
2008-04-19 12:47 ` Sebastien
2008-04-19 13:39 ` Ludovic Brenta
2008-04-21 10:09 ` Sébastien [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox