comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Thick bindings to a C library and gnattest: suggestions?
Date: Mon, 1 Jul 2013 14:42:09 +0200
Date: 2013-07-01T14:42:09+02:00	[thread overview]
Message-ID: <1xu1l42fr7m7r.1prlqkgvrb2e1.dlg@40tude.net> (raw)
In-Reply-To: f8cd0769-9423-45ef-bf78-7a5ac77dffc2@googlegroups.com

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

  reply	other threads:[~2013-07-01 12:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  9:02 Thick bindings to a C library and gnattest: suggestions? ziotom78
2013-07-01  9:45 ` Dmitry A. Kazakov
2013-07-01 11:11   ` Maurizio Tomasi
2013-07-01 11:41     ` Simon Wright
2013-07-01 12:00       ` Maurizio Tomasi
2013-07-01 12:42         ` Dmitry A. Kazakov [this message]
2013-07-01 19:07           ` Simon Wright
2013-07-01 12:32     ` Dmitry A. Kazakov
2013-07-01 12:41       ` Maurizio Tomasi
2013-07-01 12:47       ` Simon Wright
2013-07-02  8:55     ` Georg Bauhaus
2013-07-02  8:33   ` Maurizio Tomasi
2013-07-02  8:58     ` Dmitry A. Kazakov
2013-07-02 16:58     ` Robert A Duff
2013-07-02 17:00     ` Jeffrey Carter
2013-07-01 17:16 ` Jeffrey Carter
2013-07-02  4:24   ` Randy Brukardt
2013-07-02  4:37     ` Shark8
2013-07-02  5:04     ` tmoran
2013-07-02 22:27       ` Randy Brukardt
2013-07-03 12:02   ` Jacob Sparre Andersen
2013-07-02  3:16 ` Jerry
2013-07-02  4:02   ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox