Search code examples
adagnat

Compilation with GNATColl


I have installed GNAT 2018 (64 bits) on a PC Windows 8.1. GNATColl seems well present and compiled through repertories :

C:/GNAT/2018/include/gnatcoll
C:/GNAT/2018/lib/gnatcoll.static

I try to compile this small test program :

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;  

with the command :

gnatmake -gnat12 -gnatf -O3 "Test_Colors.adb" -aIC:/GNAT/2018/include/gnatcoll  -aLC:/GNAT/2018/lib/gnatcoll.static

The file Test_Colors.ali is well created but then the binding goes wrong :

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.

Do you know what to do to use successfully GNATColl ?


Solution

  • Jacob’s project file will indeed build (assuming you have your source in a subdirectory \src and are happy with having your executable in \bin), but this one is a lot simpler:

    with "gnatcoll";
    project Test_Colors is
       for Main use ("test_colors.adb");
    end Test_Colors;
    

    The other options he shows will be extremely useful as you develop more advanced projects.