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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: GPS: Including C headers from paths which are not configured in Source_Dirs Date: Thu, 08 Oct 2015 21:49:29 +0100 Organization: A noiseless patient Spider Message-ID: References: <8a324b12-4774-4a73-9e6e-c2b87d80f4e8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="82b7f55adeea1ed21a93abb5e24a046f"; logging-data="30266"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19R9/Dx/ieHTOsfb9VR8ixdBEHst6wb68s=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:zU1/d0ia4bDorvLvh+28ju7G4uA= sha1:gU6oreqP9cT3lqvW0dFhRmnQhFE= Xref: news.eternal-september.org comp.lang.ada:27942 Date: 2015-10-08T21:49:29+01:00 List-Id: "Rego, P." writes: > On Thursday, October 8, 2015 at 12:29:32 PM UTC-3, Simon Wright wrote: >> package Compiler is >> for Switches ("C") use ("-I/your/include/dir"); >> end Compiler; > > It did not work, maybe I did wrong. I built a test code to analyze better. > > --test.gpr > project Test is > for Languages use ("Ada", "C"); > for Source_Dirs use ("."); > for Main use ("ohmy.adb"); > > package Compiler is > for Switches ("C") use ("-Ioutsiders"); > end Compiler; > > end Test; > > --ohmy.adb > procedure Ohmy is > procedure Put_Ohmy; > pragma Import (C, Put_Ohmy, "putOhmy"); > begin > Put_Ohmy; > end Ohmy; > > --bla.h > void putOhmy(void); > > --bla.c > #include > #include "common/bla_other.h" > > void putOhmy (void) { > putOhmyOther(); > } This clearly worked as intended, because bla.c got compiled. > --outsiders/common/bla_other.h > void putOhmyOther(); > > --outsiders/common/bla_other.c > #include > #include > > void putOhmyOther(){ > printf("Ohmy"); > } But .. > In this case, the built returns the error message: >> gprbuild -d -Ptest.gpr ohmy.adb >> gcc ohmy.o -o ohmy.exe >> libtest.a(bla.o):bla.c:(.text+0x7): undefined reference to `putOhmyOther' >> collect2.exe: error: ld returned 1 exit status >> gprbuild: link of ohmy.adb failed >> [2015-10-08 13:38:54] process exited with status 4, 100% (2/2), >> elapsed time: 03.94s This is telling you that outsiders/common/bla_other.o never got included in the link (probably never got compiled, either). I take it that the outsiders directory corresponds to an externally-built C library in your real application? Perhaps you could represent it as a GPR of its own? library project Outsiders is for Library_Name use "outsiders"; for Library_Kind use "static"; for Library_Dir use project'Project_Dir & "src"; for Source_Dirs use project'Project_Dir & "include"; for Externally_Built use "true"; end Outsiders; and then your test.gpr might say with Outsiders; project Test is for Languages use ("Ada", "C"); for Source_Dirs use ("."); for Main use ("ohmy.adb"); package Compiler is for Switches ("C") use ("-I" & Outsiders'Source_Dirs); end Compiler; end Test;