5

I downloaded the GNAT Community 2019 and have installed on my Mac in my home folder "/Users/leon/opt/GNAT"

I run the command "gps" in the directory "/Users/leon/opt/GNAT/2019/bin". And GPS showed up, then I created a project, typed the "Hello World" code. Just as the Wikibook shows.

with Ada.Text_IO;

procedure Hello is
begin
   Ada.Text_IO.Put_Line("Hello, world!");
end Hello;

When I clicked the build button, the program just failed to build.

The following is the building output.

gprbuild -d -P/Users/leon/Documents/ada/helloworld.gpr /Users/leon/Documents/ada/src/hello.adb
Compile
   [Ada]          hello.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of hello.adb failed
gprbuild: failed command was: /users/leon/opt/gnat/2019/bin/gcc hello.o b__hello.o -L/Users/leon/Documents/ada/obj/ -L/Users/leon/Documents/ada/obj/ -L/users/leon/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/leon/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 hello
[2020-02-28 22:36:48] process exited with status 4, elapsed time: 00.79s

Please help. I can't figure out what is wrong with the configuration or something. Thank you in advance.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Leon R. Wood
  • 193
  • 1
  • 6
  • 1
    Simon will be along any minute. Macs are a little weird and keep changing, so it would probably be really good to add the model and especially the exact OS revision to the question. –  Feb 28 '20 at 15:21
  • Hi, Brian. My MacOS version is 10.15.3 – Leon R. Wood Feb 28 '20 at 15:23
  • OK in outline, the linker can't find the RTS or the System library, that much is obvious. I've seen rumours that /usr/include moved somewhere else but I don't know which OS revision did that. Also MacOS needs "Xcode" to be installed for SW development ... which Xcode version do you have? Beyond that, I can't help. –  Feb 28 '20 at 15:29
  • The Xcode version is 11.3.1 – Leon R. Wood Feb 28 '20 at 15:35
  • 2
    I wrote this up [here](https://forward-in-code.blogspot.com/2019/06/macos-software-development-kit-changes.html). – Simon Wright Feb 29 '20 at 08:40
  • @BrianDrummond and Simon Wright upvoted, when dealing with Mac world and Ada its worth giving all versions at hand. I once struggled *for days* about some weird linker warnings only to find out that an (unwanted) XCode update messed up the whole gnat toolchain (spoiler, it had to do with iOS cross compilation) – LoneWanderer Apr 17 '20 at 12:08

1 Answers1

8

guys. I found the solution myself.

On the program's download's page, above the program's link, there is a README file.

I ignored it at first. Just then I revisited the official site and read the README file and got the solution as following :

== Mac OS: Xcode is now needed ==

On Mac OS, GNAT Community 2019 requires Xcode version 10 or above to be
installed. Once you do have Xcode installed, if you still observe an error
of the form:

  ld: library not found for -lSystem

then you might have to execute the following:

  xcode-select -s /Applications/Xcode.app/Contents/Developer

I think this has really given me a great lesson. READ THE INSTALLATION MANUAL FIRST.

Thank you guys.

Leon R. Wood
  • 193
  • 1
  • 6
  • you're allowed to accept your own answer. Might give it a day first, in case a better one comes along. –  Feb 28 '20 at 17:35
  • For what it's worth, one may have trouble with `xcode-select`, most common issue is https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error – LoneWanderer Apr 17 '20 at 12:03