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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Thick bindings to a C library and gnattest: suggestions? Date: Mon, 1 Jul 2013 14:42:09 +0200 Organization: cbb software GmbH Message-ID: <1xu1l42fr7m7r.1prlqkgvrb2e1.dlg@40tude.net> References: <1fxsf70zl2ckq.aysy7d9c8jkl$.dlg@40tude.net> <40bf5a31-b09a-4106-a57a-7ac3dd5f951e@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: IenaDxMXK2hi7fvYcb+MlQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:16010 Date: 2013-07-01T14:42:09+02:00 List-Id: On Mon, 1 Jul 2013 05:00:50 -0700 (PDT), Maurizio Tomasi wrote: > Many thanks Simon, my problem was that I cannot decide "a priori" when to > link statically and when dynamically, but you helped me in devise a > solution: > > project cfitsio is > for Externally_Built use "true"; > for Source_Files use (); > for Library_Dir use external("CFITSIO_LIB_DIR"); > for Library_Name use "cfitsio"; > for Library_Kind use external("CFITSIO_LINKING"); > end cfitsio; > > On my laptop running Linux Mint I have both the static and dynamic > versions of CFITSIO, and now I am able to compile them using these > commands: > > CFITSIO_LIB_DIR=/usr/lib/x86_64-linux-gnu CFITSIO_LINKING=dynamic gprbuild test_driver.gpr > > CFITSIO_LIB_DIR=/usr/lib/ CFITSIO_LINKING=static gprbuild test_driver.gpr > > So, one of my problems is fully solved! Use scenario variables instead of environment variables: type Library_Type is ("static", "dynamic"); Linkage : Library_Type := external ("Linkage", "static"); case Linkage is -- You could do it directly without case, but when "static" => -- case illustrates how powerful this method is for Library_Kind use "static"; when "dynamic" for Library_Kind use "dynamic"; end case; Scenario variables appear in GPS and can be selected there on the fly. When compiled using gnatmake or gprbuild you specify them this way: gnatmake -Pmy_project.gpr -XLinkage="dynamic" -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de