comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Ada file depends on C file
Date: Thu, 17 Sep 2009 06:07:19 -0700 (PDT)
Date: 2009-09-17T06:07:19-07:00	[thread overview]
Message-ID: <4205125b-ccae-4ec0-894f-c53976ecca7c@p23g2000vbl.googlegroups.com> (raw)
In-Reply-To: 87bfc895-8c74-4fe9-86b6-99416006ab65@z34g2000vbl.googlegroups.com

mockturtle wrote on comp.lang.ada:
> Dear all,
> I have a question that I am afraid is awfully trivial, but I spent
> half a morning without finding any answer.
>
> My setup: I am working with GPS and I have an Ada procedure (say
> Interface_to_Addr in foo.adb) that needs to call a small C function
> (char *interface_to_ip (char*)) defined in interface_to_ip.c.  So, in
> my Ada code I wrote
>
>    function interface_to_ip(interf : chars_ptr)  return chars_ptr;
>    pragma Import(C, interface_to_ip);
>
> Everything compiles fine, but when it is time to link, the linker
> complains (correctly) that it cannot find "interface_to_ip".  The
> problem is that the compiler does not know that interface_to_ip is in
> interface_to_ip.c, or, in other words, it does not know that foo.adb
> depends on interface_to_ip.c.
>
> Currently I solved by adding the line
>
>     pragma Linker_Options("../../interface_to_ip.o");
>
> and by compiling "by hand" interface_to_ip.c to interface_to_ip.o, but
> this solution is *UGLY*.
>
> Everything would be fine if I could tell to the compiler that foo.adb
> depends on interface_to_ip.c, but I do not know how to do it.  I
> looked under the GPS "Project" menu, browsed the GNAT user & reference
> manuals (although not in the deepest detail) and googled for a while,
> but I could not find an answer.
>
> Thank you in advance for your help.

I normally use a Makefile to compile in such situations but there are
two alternatives: gprmake and its successor, gprbuild. In GPS, you can
specify that your project is multi-language; this will cause it to
call the proper tool (instead of gnatmake, which is for Ada-only
projects). I cannot be more specific as I don't use GPS myself.
Hopefully the project manager interface in GPS should be intuitive
enough.

--
Ludovic Brenta.



  reply	other threads:[~2009-09-17 13:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17 12:38 Ada file depends on C file mockturtle
2009-09-17 13:07 ` Ludovic Brenta [this message]
2009-09-17 13:32   ` mockturtle
2009-09-17 14:49     ` Ludovic Brenta
2009-09-17 16:17       ` Dmitry A. Kazakov
2009-09-17 17:35         ` mockturtle
2009-09-17 13:29 ` Dmitry A. Kazakov
replies disabled

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