我在PC Windows 8.1上安装了GNAT 2018(64位)。 GNATColl似乎很好地存在并通过库存编译:
C:/ GNAT / 2018 /包含/ gnatcoll
C:/GNAT/2018/lib/gnatcoll.static
我尝试编译这个小测试程序:
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;
使用命令:
gnatmake -gnat12 -gnatf -O3 "Test_Colors.adb" -aIC:/GNAT/2018/include/gnatcoll -aLC:/GNAT/2018/lib/gnatcoll.static
文件Test_Colors.ali创建良好,但绑定出错:
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吗?
答案 0 :(得分:1)
使用项目文件和gprbuild
。这些方面的东西:
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;
现在您可以使用以下命令构建程序:
gprbuild -j0 -p -P colors.gpr
如果你运行命令的目录中没有任何其他项目文件,那就更简单了:
gprbuild -j0 -p
答案 1 :(得分:1)
雅各布的项目文件确实会构建(假设您的源代码在\src
子目录中,并且对\bin
中的可执行文件感到满意),但这个文件要简单得多:
with "gnatcoll";
project Test_Colors is
for Main use ("test_colors.adb");
end Test_Colors;
当您开发更高级的项目时,他展示的其他选项将非常有用。