Search code examples
adagnat-gps

GNAT Studio - Cant use non-core Ada librairies


I am new to Ada programing and I am trying to learn it using the GNAT Studio IDE.

There is no problem using the core librairies like Ada.Text_IO or Ada.Numerics, but when I try to use Libadalang for exemple, the compiler doesnt find the specification file "libadalang.ads".

My code :

with Ada.Text_IO;
with Libadalang.Analysis;
procedure Main is

begin
   --  Insert code here.
   null;
end Main;

When I hit the "Build and Run" button, I get the folowing output :

gprbuild -d -PD:\Users\xxx\prog\ada_workspace\testlibadalang_1\testlibadalang_1.gpr D:\Users\xxx\prog\ada_workspace\testlibadalang_1\src\main.adb
Compile
   [Ada]          main.adb
main.adb:2:06: file "libadalang.ads" not found
gprbuild: *** compilation phase failed
[2020-09-22 19:02:49] process exited with status 4, elapsed time: 01.36s

I looked for this file in the GNAT Studio installation folder and I found it in C:\GNAT\2020\include\libadalang with all the other ".ads" and ".adb" files of libadalang.

Is there any way to "tell" GNAT Studio to search in this directory in order to be able to call them with the "with" keyword ? Or should I do something completely different with the aim of using Libadalang ?

Btw, sorry for my bad english.

Thank you.


Solution

  • You need to reference libadalang in your project file (testlibadalang_1.gpr). GNAT Studio offers a GUI to do that:

    • Right click on the project, choose Properties.
    • In the Properties window, select Sources -> Dependencies.
    • In this view, you should find libadalang in the list of known projects and drag it to the dependencies list.

    When editing the project file manually, you would put with "libadalang.gpr"; at the top of the file, assuming that it is located in a directory that is part of the GPR_PROJECT_PATH.