From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,7c6bcf9f4b4496b1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!p23g2000vbl.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Ada file depends on C file Date: Thu, 17 Sep 2009 06:07:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4205125b-ccae-4ec0-894f-c53976ecca7c@p23g2000vbl.googlegroups.com> References: <87bfc895-8c74-4fe9-86b6-99416006ab65@z34g2000vbl.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1253192839 20590 127.0.0.1 (17 Sep 2009 13:07:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 17 Sep 2009 13:07:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p23g2000vbl.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8364 Date: 2009-09-17T06:07:19-07:00 List-Id: 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. =A0So, in > my Ada code I wrote > > =A0 =A0function interface_to_ip(interf : chars_ptr) =A0return chars_ptr; > =A0 =A0pragma 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". =A0The > 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 > > =A0 =A0 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. =A0I > 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.