Search code examples
adagnat-gps

GPS not showing GTKAda application on Build & Run


I was wanting to play a bit with GPS am using the following program which is just from a template generated by GPS.

When I try to Build & Run I see no Window, however if I navigate to the folder where the executable was made, I can run the executable and see the window. I can see this tab was created, but I don't see my application.

with Gtk.Box;         use Gtk.Box;
with Gtk.Label;       use Gtk.Label;
with Gtk.Widget;      use Gtk.Widget;
with Gtk.Main;
with Gtk.Window;      use Gtk.Window;

procedure Main is

   Win   : Gtk_Window;
   Label : Gtk_Label;
   Box   : Gtk_Vbox;

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);

   --  Add a label
   Gtk_New (Label, "Hello world.");
   Box.Add (Label);

   --  Show the window
   Win.Show_All;

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

GPS Tab Run

I even tried making sure my program was being ran, and put Ada.Text_IO.Put_Line("Hello, World!"); in the source, and it does seem to be running according to the Run tab.


Solution

  • I had the same issue. You need to add a “windows GUI” directive to the linker.

    Go to Project/Properties, under Build/Switches/Ada Linker add this directives in the field

    -Wl,--subsystem,windows
    

    Or put it in your gpr file Linker section as follows:

    package Linker is
      case Library_Type is
    
         when "static" =>
            for Switches ("ada") use ("-Wl,--subsystem,windows");
    
         when "static-pic" =>
    
         when "relocatable" =>
    
      end case;
    end Linker;