我应该如何解决 GNAT GPS "library not found" 问题并在我的 Mac 上构建我的第一个 "Hello World" 程序?

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

我下载了 GNAT Community 2019 并安装在我的 Mac 主文件夹“/Users/leon/opt/GNAT”

我在目录“/Users/leon/opt/GNAT/2019/bin”中运行命令"gps"。 GPS 出现了,然后我创建了一个项目,输入了 "Hello World" 代码。正如 Wikibook 所示。

with Ada.Text_IO;

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

当我点击构建按钮时,程序构建失败。

以下是构建输出。

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

请帮忙。我无法弄清楚配置有什么问题。提前谢谢你。

伙计们。我自己找到了解决方案。

在程序的下载页面上,程序 link 上方,有一个 README 文件。

起初我忽略了它。就在这时,我重新访问了官方网站并阅读了 README 文件,得到了如下解决方案:

== Mac OS: 现在需要 Xcode ==

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

我觉得这真的给我上了很好的一课。请先阅读安装手册。

谢谢大家