Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Shared libr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 9 Topic 5660 of 5827
Post > Topic >>

Re: Shared library in Ada

by Ludovic Brenta <ludovic@[EMAIL PROTECTED] > Apr 19, 2008 at 03:39 PM

Sebastien <seb.morand@[EMAIL PROTECTED]
> 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 Im****t or pragma Ex****t.

- 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.
 




 9 Posts in Topic:
Shared library in Ada
Sebastien <seb.morand@  2008-04-19 13:27:24 
Re: Shared library in Ada
Georg Bauhaus <rm.tsoh  2008-04-19 13:41:14 
Re: Shared library in Ada
Sebastien <seb.morand@  2008-04-19 13:51:31 
Re: Shared library in Ada
Robert A Duff <bobduff  2008-04-19 11:31:17 
Re: Shared library in Ada
Ludovic Brenta <ludovi  2008-04-19 13:52:32 
Re: Shared library in Ada
Sebastien <seb.morand@  2008-04-19 13:55:16 
Re: Shared library in Ada
Sebastien <seb.morand@  2008-04-19 14:47:43 
Re: Shared library in Ada
Ludovic Brenta <ludovi  2008-04-19 15:39:38 
Re: Shared library in Ada
=?ISO-8859-1?Q?S=E9bastie  2008-04-21 10:09:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:16:13 CDT 2008.