N7SD logo

HOME      INDEX

Running “box” from testgtk via Alire


Minimal Setup: Run testgtk “Containers” – “box” with Alire

Date: June 28 2025
Confirmed versions:
Ubuntu: 24.04.2 LTS, Gnat: 14.2.1, Gtkada:25.0.1
PC: OMEN 17-ck2095cl, i9-13900HX, RTX-4080

Application "Box" screen

Setup Build Space “box” for “create_box”

~/ada/s_testgtk$ alr init box –bin

Alire needs some user information to initialize the crate author and maintainer,
for eventual submission to the Alire community index. This information will be
interactively requested now.
You can edit this information at any time with ‘alr config’
Enter a short description of the crate: (default: ”)

Enter
Using default: ”
Please enter your email address: (default: ‘example@example.com’)
Enter
Using default: ‘example@example.com’
Select a software license for the crate?

  1. MIT OR Apache-2.0 WITH LLVM-exception
  2. MIT
  3. Apache-2.0 WITH LLVM-exception
  4. Apache-2.0
  5. BSD-3-Clause
  6. LGPL-3.0-or-later
  7. GPL-3.0-or-later WITH GCC-exception-3.1
  8. GPL-3.0-or-later
  9. Other…
    Enter your choice index (#1 is default):
    Enter
    Enter a comma (‘,’) separated list of tags to help people find your crate: (default: ”)
    Enter
    Using default: ”
    Enter an optional Website URL for the crate: (default: ”)
    Enter
    Using default: ”
    ✓ box initialized successfully.

Setup gtkada Environment

~/ada/s_testgtk$ cd box

/ada/s_testgtk/box$ alr with gtkada

◴ Updating index... remote: Enumerating objects: 126, done.
remote: Counting objects: 100% (99/99), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 126 (delta 57), reused 77 (delta 48), pack-reused 27 (from 1)
Receiving objects: 100% (126/126), 47.03 KiB | 3.62 MiB/s, done.
Resolving deltas: 100% (61/61), completed with 17 local objects.
From https://github.com/alire-project/alire-index
   4f64614..f814b95  stable-1.3.0 -> origin/stable-1.3.0
   01882d3..c8f57b5  stable-1.4.0 -> origin/stable-1.4.0
Updating 4f64614..f814b95
Fast-forward
 index/pr/press_utils/press_utils-1.0.0.toml           | 15 +++++++++++++++
 .../sparkfun_qwiic_motor_driver-0.1.0.toml            | 19 +++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 index/pr/press_utils/press_utils-1.0.0.toml
 create mode 100644 index/sp/sparkfun_qwiic_motor_driver/sparkfun_qwiic_motor_driver-0.1.0.toml
◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                             ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                            ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                                                                                                                ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                                ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                                ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)... Looking for e.                                                                                Requested changes:
✓ gtkada ^25.0.1 (add)
Changes to dependency solution:
   +   gtkada     25.0.1  (new)
   +📦 libgtk3    3.24.41 (new,indirect,system package)
   +📦 make       4.3.0   (new,indirect,system package)
   +📦 pkg_config 1.8.1   (new,indirect,system package)

Do you want to proceed?
[Y] Yes  [N] No  (default is Yes) Yes

~/ada/s_testgtk/box$ alr build
ⓘ Building box=0.1.0-dev/box.gpr…
Setup
[mkdir] object directory for project Box
[mkdir] exec directory for project Box
Compile
[Ada] box.adb
Bind
[gprbind] box.bexch
[Ada] box.ali
Link
[link] box.adb
✓ Build finished successfully in 0.67 seconds.

Setup Source Files

Copy 2 files from the testgtk directory into src directory.
create_box.ads
creat_box.adb

https://github.com/AdaCore/gtkada/tree/master/testgtk

~/ada/s_testgtk/box$ ls -al
total 40
drwxrwxr-x 2 mm mm 4096 Jun 17 14:41 .
drwxrwxr-x 8 mm mm 4096 Jun 17 14:36 ..
-rw-rw-r– 1 mm mm 41 Jun 17 14:34 box.adb
-rw-rw-r– 1 mm mm 6994 Jun 17 14:38 create_box.adb
-rw-rw-r– 1 mm mm 1894 Jun 17 14:39 create_box.ads

Edit Source Files

cairo.adb is auto-created file

~/ada/s_testgtk/box/src$ cat box.adb

~/ada/s_testgtk/box/src$ cat box.adb
procedure Box is
begin
   null;
end Box;

Edit main program box.adb

with Gdk.Event;       --  use Gdk.Event;
--  with label;    use Label;
--  with Gdk;             use Gdk;
with Gtk.Box;         use Gtk.Box;
with Gtk.Widget;      use Gtk.Widget;
with Gtk.Main;
with Gtk.Window;      use Gtk.Window;

--  ****** Add DEFINITION ***********
with Gtk.Frame;       use Gtk.Frame;
with Create_Box;
--  **********************************

procedure Box is

   Win   : Gtk_Window;
   Box   : Gtk_Vbox;
   Frame1  : Gtk_Frame;  --  ****** ADD DEFINITION

   function Delete_Event_Cb
     (Self  : access Gtk_Widget_Record'Class;
      Event : Gdk.Event.Gdk_Event)
      return Boolean;

   ---------------------
   -- Delete_Event_Cb --
   ---------------------

   function Delete_Event_Cb
     (Self  : access Gtk_Widget_Record'Class;
      Event : Gdk.Event.Gdk_Event)
      return Boolean
   is
      pragma Unreferenced (Self, Event);
   begin
   --  Close all child windows before closing main loop
      Win.Destroy;
      Gtk.Main.Main_Quit;
      return True;
   end Delete_Event_Cb;

----  Main Program ---------------------
begin
   --  Initialize GtkAda.
   Gtk.Main.Init;

   --  Create a window with a size of 400x400
   Gtk_New (Win);
   Win.Set_Default_Size (400, 400);

   --  Create a box to organize vertically the contents of the window
   Gtk_New_Vbox (Box);
   Win.Add (Box);

   Gtk.Frame.Gtk_New (Frame1);
   Add (Box, Frame1);
   Create_Box.Run (Frame1);   --  **** CALL Package.Procedure *******

   --  Stop the Gtk process when closing the window
   Win.On_Delete_Event (Delete_Event_Cb'Unrestricted_Access);

   --  Show the window and present it
   Win.Show_All;
   Win.Present;

   --  Start the Gtk+ main loop
   Gtk.Main.Main;
end Box;

Startup GnatStudio with Alire

~/ada/s_testgtk/box$ alr edit

GnatStudio screen

File box.gpr opens as above screen automatically.

Change Project Files (gpr)

File box.gpr before modification:

with "config/box_config.gpr";
project Box is

   for Source_Dirs use ("src/", "config/");
   for Object_Dir use "obj/" & Box_Config.Build_Profile;
   for Create_Missing_Dirs use "True";
   for Exec_Dir use "bin";
   for Main use ("box.adb");

   package Compiler is
      for Default_Switches ("Ada") use Box_Config.Ada_Compiler_Switches;
   end Compiler;

   package Binder is
      for Switches ("Ada") use ("-Es"); --  Symbolic traceback
   end Binder;

   package Install is
      for Artifacts (".") use ("share");
   end Install;

end Box;

Modify box.gpr. 

Add the following line at the next of “for Main use (“box.adb”);

for Source_Files use (“create_box.adb”, “create_box.ads”, “box.adb”);

File box.gpr after the modification

with "config/box_config.gpr";
project Box is

   for Source_Dirs use ("src/", "config/");
   for Object_Dir use "obj/" & Box_Config.Build_Profile;
   for Create_Missing_Dirs use "True";
   for Exec_Dir use "bin";
   for Main use ("box.adb");
   for Source_Files use ("common.adb", "common.ads", "create_box.adb", "create_box.ads", "box.adb");
   
   package Compiler is
      for Default_Switches ("Ada") use Box_Config.Ada_Compiler_Switches;
   end Compiler;

   package Binder is
      for Switches ("Ada") use ("-Es"); --  Symbolic traceback
   end Binder;

   package Install is
      for Artifacts (".") use ("share");
   end Install;

end Box;

Build

Build all icon

Build message

gprbuild -d -P/home/mm/ada/s_testgtk/box/box.gpr -XLIBRARY_TYPE=static -XBUILD=Production -XGTK_PREFIX=/home/mm/.local/share/alire/builds/gtkada_25.0.1_d3787772/05561da954afaee17128f59bba699db2f2e4a4215317b2b818a8016192c82334/ -XOBJCFLAGS= -XLDFLAGS= -XCPPFLAGS= -XCFLAGS= -XADAFLAGS=
Compile
   [Ada]          box.adb
box.adb:70:01: (style) blank line not allowed at end of file [-gnatyu]
Bind
   [gprbind]      box.bexch
   [Ada]          box.ali
Link
   [link]         box.adb
[2025-06-17 15:03:05] process terminated successfully, elapsed time: 01.10s

Execution

Execution must be done in Terminal mode.
~/ada/s_testgtk/box$ cd bin
~/ada/s_testgtk/box/bin$ ./box