Beginner help: file not found error with example code

Hi, I’m new to Ada.
I’m reading the book by John Barnes and tried to run an example from it, but I keep getting a “file not found” error.
I’d really appreciate it if anyone has time to help.

Hello_World is the “main” procedure.

content of geometry folder:

shapes.ads

i get hello_world.adb:5:06: error: file “geometry-shapes.ads” not found

Hi.
Please post the contents of hello_world.adb and the command you’re using when trying to compile this project.

The package Geometry.Shapes must be in a file named geometry-shapes.ads and geometry-shapes.adb for the body.

3 Likes

for compilation just following:
alr run

solved thanks to @Jesper-Quorning

You might find useful info in this other topic: What kind of package declaration is this?

1 Like

This is not true. The GNAT compiler, by default, expects units to be in files named as you described. There are ways to tell GNAT that units are in files with different names, such as the gnatname tool. Most other compilers, such as ObjectAda, always accept units in files with any names.

As the OP is clearly using GNAT, your response was helpful at this time, but might become confusing if the OP uses another compiler. It’s important to distinguish between the language and the idiosyncrasies of specific tools.

2 Likes