From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal 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!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to supply O/S linker arguments with gprbuild? Date: Mon, 22 Jun 2020 18:39:02 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com> NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59163 List-Id: On 22/06/2020 17:51, Warren wrote: > I have a GNAT project that has these pragma statements embedded to get the sucker to link. However, the directory is only valid for an instance on my Mac, so I need a better solution to replace: > > pragma Linker_Options("-L/usr/local/Cellar/readline/8.0.4/lib"); > pragma Linker_Options("-lreadline"); > > I've tried to find the solution in the gnat documents but they seem to fall short of what I need to do (could not find an example nor direction in this -- perhaps I missed it). > > My project file looks something like this: > > project MyProject is > for Languages use ("ada", "c"); > for Source_Dirs use ("src"); > for Object_Dir use "obj"; > for Main use ("main.adb"); > end MyProject; > > I've tried a variety of gpr things, but unsuccessfully. There are many ways to do this. Here I give one rarely used but most flexible and consistent with the idea of projects. If you have an alien library like readline, you can pack it in a separate library project like this: project Readline is for Externally_Built use "true"; -- Do not build it for Source_Files use (); -- No sources for Library_Dir use "/usr/local/Cellar/readline/8.0.4/lib"; for Library_Name use "readline"; -- OS naming conventions applied for Library_Kind use "dynamic"; -- Or static, end Readline; -- depending on what you have In your project or projects you would simply do with "readline.gpr"; and that is all. Adjust the above using a scenario variable to select the target OS, e.g. type OS_Type is ( "Windows", "Windows_NT", "Linux", "UNIX", "OSX", "FreeBSD", ... ); Target_OS : OS_Type := external ("Target_OS", "MS-DOS"); case Target_OS is when "ms-dos" => for Library_Dir use "..."; when "osx" => for Library_Dir use "..."; ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de