comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <pascal@obry.net>
To: Alex Mentis <foo@invalid.invalid>
Subject: Re: Import pragma question
Date: Wed, 23 Mar 2011 09:45:17 +0100
Date: 2011-03-23T09:45:17+01:00	[thread overview]
Message-ID: <4D89B31D.8010203@obry.net> (raw)
In-Reply-To: <imcaor$u2l$1@news.eternal-september.org>


Alex,

> I've never interfaced Ada with other languages, so I have some
> questions about pragma Import. How does an import pragma know where to
> find the non-Ada code to be used for the import?

By passing the corresponding object file or library to the linker.  No 
magic! With GNAT you can use:

    $ gnat make main.adb -largs -lmylib

And possibly the PATH to this library with -L<path>/<to>/<lib>.

Where mylib.a (or mylib .dll or .so) contains the symbols from the 
foreign language. Another option is to a add a pragma Linker_Options 
into one of the sources.

    pragma Linker_Options ("-lmylib");

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




  reply	other threads:[~2011-03-23  8:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23  8:25 Import pragma question Alex Mentis
2011-03-23  8:45 ` Pascal Obry [this message]
2011-03-23  8:45 ` Pascal Obry
2011-03-23  9:06   ` Alex Mentis
2011-03-23 16:51 ` Jeffrey Carter
2011-03-23 17:40   ` Alex Mentis
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox