Search code examples
ubuntuadagnat

How to setup alternative path for binding (Gnat ADA)


I try to compile a sample ada sourcefile, using libncursesada binding. Gnat, during compilation, can't find libncursesada, installed with apt-get.

Software configuration : GNAT 7.3.0 xubuntu 18.04

code :

-- hello.adb

with Terminal_Interface.Curses; use Terminal_Interface.Curses;

procedure Hello is
  C : Key_Stroke;
  Msg : String := "Hello, world!";

begin
  Init_Windows;          
  Add(Standard_Window, Msg, Msg'Length); 
  Refresh;                              
  C := Get_Keystroke;                  
  End_Windows;                        
  Curses_Free_All;
end Hello;

Compilation error :

gnat compile hello.adb
gcc-7 -c hello.adb
hello.adb:1:06: file "terminal_interface.ads" not found
gnatmake: "hello.adb" compilation error

libncursesada packages are installed with apt-get :

libncursesada-doc/bionic,bionic,now 6.0.20170708-2 all  [installé]
  Ada binding to the ncurses text interface library: documentation

libncursesada5/bionic,now 6.0.20170708-2 amd64  [installé, automatique]
  Ada binding to the ncurses text interface library: shared library

libncursesada5-dev/bionic,now 6.0.20170708-2 amd64 

Files can be fount into this directory : /usr/share/ada/adainclude/ncursesada/

/usr/share/ada/adainclude/ncursesada$ ls -l terminal_interface.*
-rw-r--r-- 1 root root 3115 août   9  2017 terminal_interface.ads

When I compile using a standard binding (Gnat.IO for example), all is ok, so I suppose I must specify where to find this other binding ads file to compiler.

I can't find instructions about this into this binding documentation (libncursesada-doc folder), how to setup for compiling and linking.

What is the recommended way ?

I have read some instructions for other additionnals bindings, like add path to PATH or LD_LIBRARY_PATH into .bashrc. A parameter to add into a gpr file ?

Thanks.

Best regards.


Solution

  • libncursesada-dev includes a GPRBuild project file:

    /usr/share/ada/adainclude/ncursesada.gpr
    

    So the easiest way to link against it would be to use GPRBuild as build system:

    with "ncursesada";
    
    project Hello is
       -- should suffice for your example
       for Main use ("hello.adb");
    end Hello;
    

    You may need to set the GPR_PROJECT_PATH environment variable to include /usr/share/ada/adainclude so that the ncursesada.gpr project can be found; I am unsure whether debian sets that up correctly for you.

    Having saved the above as hello.gpr, you can compile your code with

    gprbuild hello.gpr