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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada file depends on C file Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <87bfc895-8c74-4fe9-86b6-99416006ab65@z34g2000vbl.googlegroups.com> Date: Thu, 17 Sep 2009 15:29:29 +0200 Message-ID: NNTP-Posting-Date: 17 Sep 2009 15:29:29 CEST NNTP-Posting-Host: e025c40a.newsspool3.arcor-online.net X-Trace: DXC=:[Z4@DLkW4IA@P]\DMcF=Q^Z^V3H4Fo<]lROoRA^YC2XCjHcbIBX`cZ>N=R`HDNcfSJ;bb[EFCTGGVUmh?DLK[5LiR>kgB<=o^?kdjEKC X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8365 Date: 2009-09-17T15:29:29+02:00 List-Id: On Thu, 17 Sep 2009 05:38:43 -0700 (PDT), mockturtle wrote: > 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. The project file (*.gpr) has "package Linker". You can put linker options there for example: package Linker is for Default_Switches ("ada") use ("-g", "-lgmem", <...further options...>); end Linker; Alternatively, and probably better solution, would be to include the C source into the project. AFAIK GPS supports C. In that case you should be able to handle interface_to_ip.c exactly as you do Ada files. BTW, never use GPS->Project->Edit Project Properties. Notepad is your friend! (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de