[gtkada] Problem Linking a GtkAda Tutorial Program in a New Installation

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Fri Jun 5 09:34:34 CEST 2009


On Thu, 4 Jun 2009 21:55:57 -0400, you wrote:

> I looked at the gtkada.gpr file you mentioned and found it to be a project
> file for a UNIX system, and a project library file at that.

Windows has the gpr usually located in C:\GtkAda\lib\gnat.

[...]
> Contents of File:  hello.gpr  (From the GtkAda tutorial Sub-Folder
> ================               helloworld)
> 
> project Hello is
> 
>    for Main use ("hello.adb");
>    for Source_Dirs use ("C:\---MY_TEST_FOLDER_NAME---\GTKADA\Testing\helloworld");
>    for Object_Dir use "C:\---MY_TEST_FOLDER_NAME---\GTKADA\Testing\helloworld";
> 
>    package Builder is
>       for Default_Switches ("ada") use ("-IC:\GtkAda\include\gtkada");
>    end Builder;
> 
>    package Compiler is
>       for Default_Switches ("ada") use ("-g");
>    end Compiler;
> 
>    package Binder is
>       for Default_Switches ("ada") use ("-g");
>    end Binder;
> 
>    package Linker is
>       for Default_Switches ("ada") use ("-Wl,-luuid", "-lgtkada", "-lgtk-win32-2.0.dll",
> "-lgdk-win32-2.0.dll", "-latk-1.0.dll", "-lgdk_pixbuf-2.0.dll", "-ljpeg", "-lpng",
> "-lpangocairo-1.0.dll", "-lcairo.dll", "-lpangowin32-1.0.dll", "-lpango-1.0.dll",
> "-lgobject-2.0.dll", "-lgmodule-2.0.dll", "-lglib-2.0.dll", "-lintl", "-LC:\GtkAda\lib", "-LC:\GtkAda\lib\gtkada\static", "-LC:\GtkAda\include\gtkada");
>    end Linker;
> 
> end Hello;

Try just this:

with "gtkada.gpr";
project Hello is
   for Main use ("hello.adb");
end Hello;

The idea of gtkada.gpr is to provide everything a client of GtkAda might
need in order to build the application.

You could occasionally add debug and release scenarios to your project:

   type Development_Type is ("Debug", "Release");
   Development : Development_Type := external ("Development", "Debug");

   package Compiler is
      case Development is
         when "Debug" =>
            for Default_Switches ("ada") use
                     ("-gnato", "-gnatf", "-g", "-fstack-check", -gnat05");
         when "Release" =>
            for Default_Switches ("ada") use
                     ("-gnato", "-gnatf", "-O2", "-gnatn", "-gnat05");
      end case;
   end Compiler;

   package Binder is
      case Development is
         when "Debug" =>
            for Default_Switches ("ada") use ("-E");
         when "Release" =>
            for Default_Switches ("ada") use ();
      end case;
   end Binder;

   package Builder is
      case Development is
         when "Debug" =>
            for Default_Switches ("ada") use ("-g");
         when "Release" =>
            for Default_Switches ("ada") use ("-s");
      end case;
   end Builder;

   package Linker is
      case Development is
         when "Debug" =>
            for Default_Switches ("ada") use
               Gtkada.Linker'Default_Switches ("ada") & "-g" & "-mwindows";
         when "Release" =>
            for Default_Switches ("ada") use
               Gtkada.Linker'Default_Switches ("ada") & "-O2" &
                  "-mwindows";
      end case;
   end Linker;

I think the idea behind is clear. Note how Linker package takes the
switches for linking from the corresponding package of GtkAda. I.e. you
don't need cut'n'paste.

The scenario will seen in GPS, so that you can choose it for building. It
is also can be specified in the GPRBuild when you build your project from
the command line, like:

   gprbuild -XDevelopment=Release -p -P hello.gpr

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list