Unable to compile and run simple Ada application

Viewed 1162

Very new to Ada and have started to learn by doing a Hello World tutorial in GNAT GPS. I'm having a hard time figuring out an error when I compile my code. The error looks like a source file dir issue. But I'm highly unfamiliar with the error output in this type of IDE.

Here is the code I'm trying to compile and run (file: main.adb):

with Ada.Text_IO;

procedure Main is

begin
   Ada.text_IO.Put_Line("Hello world!");
   null;
end Main;

Image of code and GPS IDE

Here's the build error I'm receiving:

gprbuild -d -P/Users/myname/Desktop/Test/default.gpr /Users/myname/Desktop/Test/src/main.adb
Compile
   [Ada]          main.adb
Bind
   [gprbind]      main.bexch
   [Ada]          main.ali
Link
   [link]         main.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of main.adb failed
gprbuild: failed command was: /users/myname/opt/gnat/2019/bin/gcc main.o b__main.o -L/Users/myname/Desktop/Test/obj/ -L/Users/myname/Desktop/Test/obj/ -L/users/myname/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/myname/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,@executable_path/ -Wl,-rpath,@executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o main
[2019-10-19 11:34:54] process exited with status 4, elapsed time: 01.95s

I'm assuming I installed Ada incorrectly and or GPS. Any suggestions or thoughts? Thank you.

Update/Additional thoughts:

One other thing I'm assuming is that the project is unable to find the Ada source code since the project is saved on the /desktop?

1 Answers

I see you’re running on macOS and using GNAT CE 2019. You need to install Xcode (from the app store, under Develop).

I wrote it up here, but to summarise,

  • In future, Apple won’t provide includes in /usr/include but instead in the SDK,
  • clang knows about this but GCC doesn’t,
  • AdaCore’s response has been to generate their compiler with the system root inside the Xcode SDK,
  • the system root affects libraries as well as headers,
  • so no Xcode means no system libraries (in spite of the libraries being in /usr/lib as always!)
Related