# Making AUnit available to gprbuild

**URL:** <https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879>\
**Category:** General\
**Tags:** ada, gnat, aunit\
**Created:** [March 11, 2025, 10:08am UTC](https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879 "2025-03-11T10:08:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 11, 2025, 10:08am UTC](https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879/1 "2025-03-11T10:08:07Z")

</div>

**tldr; I have installed AUnit per the docs, but I cannot make GPRBuild “see it”**

I like doing [“test-driven learning”](https://github.com/fatso83/test-driven-learning) when learning a new language, and so I thought I would figure out how to write the most basic setup for code covered by unit tests.

I followed the [AUnit Cookbook on installation](https://docs.adacore.com/live/wave/aunit/html/aunit_cb/aunit_cb/installation_and_use.html#installing-aunit), which basically said to run `make install`, which would install aunit where gprbuild was installed (unless overridden). This seems to have worked fine:

```ada
❯ make --trace install
Makefile:61: update target 'install-clean' due to: install-clean-legacy
gprinstall -XAUNIT_BUILD_MODE=Install -XAUNIT_RUNTIME=full -XAUNIT_PLATFORM=native --uninstall --prefix=/opt/gprbuild-x86_64-linux-24.0.0-2 aunit
Uninstall project aunit
Makefile:65: update target 'install' due to: install-clean
gprinstall -XAUNIT_BUILD_MODE=Install -XAUNIT_RUNTIME=full -XAUNIT_PLATFORM=native -p -f --prefix=/opt/gprbuild-x86_64-linux-24.0.0-2 \
        --no-build-var lib/gnat/aunit.gpr
Install project AUnit

❯ v /opt/gprbuild-x86_64-linux-24.0.0-2/lib/
total 4
drwxr-xr-x 2 oscko oscko 4096 mars 11 09:51 aunit

❯ which gprbuild
/opt/gprbuild-x86_64-linux-24.0.0-2/bin/gprbuild

```

All good so far. If I now build [`examples/simple_test ` in the aunit repository](https://github.com/AdaCore/aunit/tree/master/examples/simple_test), I get an error about it not finding aunit:

```ada
❯ gprbuild -P harness.gpr
harness.gpr:1:06: imported project file "aunit" not found
gprbuild: "harness.gpr" processing failed

```

I thought that it would now find it by virtue of being in ` /opt/gprbuild-x86_64-linux-24.0.0-2/lib/`? CoPilot also suggested adding the library to the path of GPR\_PROJECT\_PATH, but that had no effect:

```ada
export GPR_PROJECT_PATH=/opt/gprbuild-x86_64-linux-24.0.0-2/lib/aunit:$GPR_PROJECT_PATH

```

I tried reading a bit up on [how shared libraries work](https://learn.adacore.com/courses/GNAT_Toolchain_Intro/chapters/gprbuild.html), but that seemed to imply that the project file of whatever library that was to be shared should include “library project”, and grepping the aunit repo for that string showed 0 results, so I am not even sure if this is a shared library or not …

The only way I managed to compile the example was directly referencing the project file from the place it was included:

```ada
aunit/examples/simple_test on  master [!?]
✦ ❯ git diff
diff --git a/examples/simple_test/harness.gpr b/examples/simple_test/harness.gpr
index f445b8d..f0347bf 100644
--- a/examples/simple_test/harness.gpr
+++ b/examples/simple_test/harness.gpr
@@ -1,4 +1,10 @@
-with "aunit";
+-- DOES NOT WORK
+-- with "aunit";
+
+-- WORKS:
+--with "../../lib/gnat/aunit.gpr";
+with "/opt/gprbuild-x86_64-linux-24.0.0-2/share/gpr/aunit.gpr";

```

Hardcoding those paths is not a very scalable approach 🙂

What am I supposed to do here to get GPRBuild to see aunit?

---

<div class="post-metadata">

**Author:** ![simonjwright](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/simonjwright/32/11_2.png) [@simonjwright](https://forum.ada-lang.io/u/simonjwright)\
**Post date:** [March 11, 2025, 12:21pm UTC](https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879/2 "2025-03-11T12:21:00Z")

</div>

Gprbuild wants AUnit’s GPR file (`aunit.gpr`) which I’d expect to see in `/opt/gprbuild-x86_64-linux-24.0.0-2/share/gpr/` (up one from the directory gprbuild is in, then down to `share/gpr`).

But then, outside Alire I like to build gcc & gprbuild together; could `aunit.gpr` have been installed with the compiler rather than with gprbuild?

If you run gprbuild with `-vh` or `-vm` (high or medium verbosity) it should tell you its gpr search path:

```ada
Checking configuration /private/var/folders/_q/fvnxz46903z9hjh38fz0lyhm0000gs/T/GPR.35059/GNAT-TEMP-000001.TMP
Setting the default project search directories
   Adding directory "/opt/gcc-15.0.1-2-aarch64/aarch64-darwin/share/gpr"
   Adding directory "/opt/gcc-15.0.1-2-aarch64/aarch64-darwin/lib/gnat"
   Adding directory "/opt/gcc-15.0.1-2-aarch64/share/gpr"
   Adding directory "/opt/gcc-15.0.1-2-aarch64/lib/gnat"
   Adding directory "/usr/aarch64-darwin/share/gpr"
   Adding directory "/usr/aarch64-darwin/lib/gnat"
   Adding directory "/usr/share/gpr"
   Adding directory "/usr/lib/gnat"

```

(only one of those actually exists!)

---

<div class="post-metadata">

**Author:** ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)\
**Post date:** [March 11, 2025, 1:35pm UTC](https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879/3 "2025-03-11T13:35:58Z")

</div>

That was it! Adjusting the install path for aunit when installing made it available.

**Related question**  
Is it it possible to adjust the globally searched paths using some environment variable or some setting that GPRBuild will use? The suggested `GPR_PROJECT_PATH` did not seem to take effect, or it was perhaps used incorrectly.

Thanks!

# Details

## Showing the default project search directories

```ada
aunit/examples/simple_test on  master [!?]
✦ ❯ gprbuild -vm
GPRBUILD 24.0.0 (2024-08-01) (x86_64-pc-linux-gnu)
Copyright (C) 2004-2024, AdaCore
using project file harness.gpr
 33 lines: No errors
TMPDIR = "/tmp/GPR.49115"
gprconfig --batch -o /tmp/GPR.49115/GNAT-TEMP-000001.TMP --target=x86_64-linux --fallback-targets --config=ada,,,,
Checking configuration /tmp/GPR.49115/GNAT-TEMP-000001.TMP
Setting the default project search directories
   Adding directory "/opt/gnat-x86_64-linux-14.2.0-1/x86_64-linux/share/gpr"
   Adding directory "/opt/gnat-x86_64-linux-14.2.0-1/x86_64-linux/lib/gnat"
   Adding directory "/opt/gnat-x86_64-linux-14.2.0-1/share/gpr"
   Adding directory "/opt/gnat-x86_64-linux-14.2.0-1/lib/gnat"

```

This shows that the sub directories of the gprbuild install was not being searched.

## Adjusting the install path for AUnit

```ada
 make install INSTALL=/opt/gnat-x86_64-linux-14.2.0-1

```

Now I could revert the change from using absolute directory paths to using global shared libraries, such as `with "aunit";`

```diff
✦ ❯ git diff
diff --git a/examples/simple_test/harness.gpr b/examples/simple_test/harness.gpr
index f445b8d..a12f6fd 100644
--- a/examples/simple_test/harness.gpr
+++ b/examples/simple_test/harness.gpr
@@ -1,4 +1,10 @@
-with "aunit";
+-- Requires Aunit to be globally available
+-- See https://forum.ada-lang.io/t/making-aunit-available-to-gprbuild/1879/2
+ with "aunit";
+-- If AUnit has not been made available, it will need to be included by path
+--with "../../lib/gnat/aunit.gpr";
+--with "/opt/gprbuild-x86_64-linux-24.0.0-2/share/gpr/aunit.gpr";
+
 with "tested_lib/testlib";

 project Harness is

```
