What should I do to solve the GNAT GPS "library not found" problem and build my first "Hello World" program on my Mac?
Asked Answered
O

1

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.

Omit answered 28/2, 2020 at 15:19 Comment(6)
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.Granny
Hi, Brian. My MacOS version is 10.15.3Omit
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.Granny
The Xcode version is 11.3.1Omit
I wrote this up here.Copartner
@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)Intestine
O
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.

Omit answered 28/2, 2020 at 16:14 Comment(2)
you're allowed to accept your own answer. Might give it a day first, in case a better one comes along.Granny
For what it's worth, one may have trouble with xcode-select, most common issue is #17981259Intestine

© 2022 - 2024 — McMap. All rights reserved.