From: Sebastien <seb.morand@gmail.com>
Subject: Re: Shared library in Ada
Date: Sat, 19 Apr 2008 14:47:43 +0200
Date: 2008-04-19T14:47:43+02:00 [thread overview]
Message-ID: <fucplb$thf$1@registered.motzarella.org> (raw)
In-Reply-To: <fucmiu$5uo$1@registered.motzarella.org>
> 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
next prev parent reply other threads:[~2008-04-19 12:47 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 [this message]
2008-04-19 13:39 ` Ludovic Brenta
2008-04-21 10:09 ` Sébastien
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox