Mac OS的链接器问题 [英] Issue with linker for Mac OS

查看:44
本文介绍了Mac OS的链接器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在系统编程课程中开始将ada用于实验室,我可以说这真的很有趣.

I have recently started using ada for a lab in my systems programming class and I can say it is really interesting.

我在计算机实验室进行了大部分测试,我决定在 MacBook 中安装编译器及其链接工具.

I tried most of it at the computers labs for testing and I decided to install the compiler and its linking tools in a MacBook.

虽然安装已完成,但似乎没有问题,当我尝试打印经典的hello world程序时,我收到以下消息:

Altough the installation is done and there seems to be no problem, when I tried to print the classic hello world program I am getting this message:

gprbuild greet.adb                                                                                                                                                                                                            
using project file /Users/xyderos/opt/GNAT/2020/share/gpr/_default.gpr
Bind
[gprbind]      greet.bexch
[Ada]          greet.ali
Link
[link]         greet.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of greet.adb failed
gprbuild: failed command was: /users/name/opt/gnat/2020/bin/gcc greet.o b__greet.o - L/Users/name/ada/ -L/Users/name/ada// -L/users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/ /users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/libgnat.a -Wl,-rpath,@executable_path/ -Wl,-rpath,@executable_path/..//opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib -o greet

我对lSystem库感到非常困惑.

I am getting really confused about the lSystem library.

该库似乎在Mac上不存在(也许我需要安装Xcode?).

It seems that the library doesn't exist on Mac(maybe I need to install Xcode?).

有人对这个问题有任何线索吗,或者有没有更好的方法可以通过brew安装它?

Does anyone have a clue about that issue or is there a probably better way to install it via brew?

非常感谢!

推荐答案

在我的MacOS 10.14上,以下代码对我有用,而不必下载Xcode庞大的Blob,而我既没有带宽也没有磁盘空间.我不知道这是否仍然可以在MacOS 10.15上使用(不打算升级).

On my MacOS 10.14, the following worked for me, without having to download the massive blob that is Xcode, which I had neither the bandwidth nor the diskspace for. I don't know if this still works on MacOS 10.15 (not planning to upgrade).

大多数信息来自Simon Wright的博客文章:

Most of this info was from a blog post by Simon Wright: https://forward-in-code.blogspot.com/2019/06/macos-software-development-kit-changes.html

  1. 您只需要Xcode命令行工具(不需要Xcode): xcode-select --install
  2. 现在解压缩包含的标题: sudo installer -pkg/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target/
  3. 然后告诉GNAT在哪里找到它们: mv ce2109-specs/usr/local/opt/GNAT/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/specs

ce2109-specs文件来自上面的博客文章.这为我完成了工作,GNAT现在可以在MacOS 10.14上链接工作二进制文件.

The ce2109-specs file is from the blog post above. This did the job for me and GNAT can now link working binaries on MacOS 10.14.

如果您使用的是10.15,但无法正常工作(因为没有更多的Xcode命令行工具,或者它们缺少标头包),那么很遗憾,您必须按照GNAT自述文件安装Xcode.

If you're on 10.15 and it doesn't work (because there's no more Xcode command line tools or they're missing the headers package), you will unfortunately have to install Xcode as per the GNAT Readme.

这篇关于Mac OS的链接器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆