【问题标题】:GPS not showing GTKAda application on Build & RunGPS 未在 Build & Run 上显示 GTKAda 应用程序
【发布时间】:2018-11-24 00:38:14
【问题描述】:

我想玩一下 GPS 我正在使用以下程序,该程序仅来自 GPS 生成的模板。

当我尝试构建和运行时,我看不到任何窗口,但是如果我导航到生成可执行文件的文件夹,我可以运行可执行文件并看到窗口。我可以看到此选项卡已创建,但我没有看到我的应用程序。

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;

我什至尝试确保我的程序正在运行,并将Ada.Text_IO.Put_Line("Hello, World!"); 放在源代码中,它似乎确实根据“运行”选项卡运行。

【问题讨论】:

    标签: ada gnat-gps


    【解决方案1】:

    这是因为它卡在了 Gtk.Main.Main 循环中。 要查看该窗口,您可以使用自定义运行命令 (Shift + F2) 并选中“在外部终端中运行”选项。

    Configure External 1

    单击执行按钮,您将看到 GtkWindow 启动并运行。

    Configure External 2

    更多详情请查看: The Build Menu - Using the GNAT Programming Studio

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。 您需要向链接器添加“windows GUI”指令。

      转到项目/属性,在 Build/Switches/Ada Linker 下的字段中添加此指令

      -Wl,--subsystem,windows
      

      或者把它放在你的 gpr 文件链接器部分,如下所示:

      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;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-26
        • 1970-01-01
        • 2012-07-19
        • 2015-08-05
        相关资源
        最近更新 更多