首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用GNATColl编译

用GNATColl编译
EN

Stack Overflow用户
提问于 2018-06-18 05:50:17
回答 2查看 295关注 0票数 0

我已经在PC Windows 8.1上安装了GNAT 2018 (64位)。GNATColl似乎很好地呈现,并通过剧目编译:

C:/GNAT/2018/include/gnatcoll

C:/GNAT/2018/lib/

我试着编译这个小测试程序:

代码语言:javascript
复制
with Ada.Text_IO;       use Ada.Text_IO;
with GNATCOLL.Terminal; use GNATCOLL.Terminal;
procedure Test_Colors is
   Info : Terminal_Info;
begin
   Info.Init_For_Stdout (Auto);
   Info.Set_Color (Standard_Output, Blue, Yellow);
   Put_Line ("A blue on yellow line");
   Info.Set_Color (Standard_Output, Style => Reset_All);
   Put_Line ("Back to standard colors -- much better");
end Test_Colors;  

有命令:

代码语言:javascript
复制
gnatmake -gnat12 -gnatf -O3 "Test_Colors.adb" -aIC:/GNAT/2018/include/gnatcoll  -aLC:/GNAT/2018/lib/gnatcoll.static

文件Test_Colors.ali很好地创建了,但是绑定出错了:

代码语言:javascript
复制
gnatbind -aIC:/GNAT/2018/include/gnatcoll -aOC:/GNAT/2018/lib/gnatcoll.static -x test_colors.ali
gnatlink test_colors.ali -O3
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x46d): undefined reference to `gnatcoll_get_console_screen_buffer_info'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x4f6): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x6c6): undefined reference to `gnatcoll_get_console_screen_buffer_info'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x729): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x73d): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x9f3): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0xc93): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0xfb4): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x1372): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x23e): undefined reference to `gnatcoll_beginning_of_line'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x28e): undefined reference to `gnatcoll_clear_to_end_of_line'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x2d8): undefined reference to `gnatcoll_terminal_width'
collect2.exe: error: ld returned 1 exit status
gnatlink: error when calling C:\GNAT\2018\bin\gcc.exe
gnatmake: *** link failed.
Compilation échouée.

你知道怎样才能成功地使用GNATColl吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-06-18 07:15:57

雅各布的项目文件确实会构建(假设您的源代码位于子目录\src中,并且乐于在\bin中执行),但这个文件要简单得多:

代码语言:javascript
复制
with "gnatcoll";
project Test_Colors is
   for Main use ("test_colors.adb");
end Test_Colors;

当您开发更高级的项目时,他展示的其他选项将非常有用。

票数 1
EN

Stack Overflow用户

发布于 2018-06-18 06:02:24

使用项目文件和gprbuild。类似于这样的东西:

代码语言:javascript
复制
with "gnatcoll";

project Colors is
   for Languages use ("Ada");

   for Main use ("test_colors.adb");

   for Source_Dirs use ("src/");
   for Object_Dir  use "obj/";
   for Exec_Dir    use "bin/";

   package Builder is
      for Default_Switches ("Ada")
        use ("-m",
             "-s");
   end Builder;

   package Compiler is
      for Default_Switches ("Ada")
        use ("-fstack-check", --  Generate stack checking code (part of Ada)
             "-gnata",        --  Enable assertions            (part of Ada)
             "-gnato13",      --  Overflow checking            (part of Ada)
             "-gnatf",                     --  Full, verbose error messages
             "-gnatwa",                    --  All optional warnings
             "-gnatVa",                    --  All validity checks
             "-gnaty3aAbcdefhiklnOprstux", --  Style checks
             "-gnatyM125",                 --  Style checks
             "-gnatwe",                    --  Treat warnings as errors
             "-gnat2012",                  --  Use Ada 2012
             "-Wall",                      --  All GCC warnings
             "-O2");                       --  Optimise (level 2/3)
   end Compiler;

end Colors;

现在,您可以使用以下命令构建程序:

代码语言:javascript
复制
gprbuild -j0 -p -P colors.gpr

如果在运行命令的目录中没有任何其他项目文件,则会更简单:

代码语言:javascript
复制
gprbuild -j0 -p
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50903280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档