Mac Ventura找不到编译器



因为我升级到OSX Ventura当我试图编译我得到消息:执行"cc1"时出错:

在尝试使用Visual Studio Code构建Ada程序时也会发生相同的情况:

   [Ada]          hello_world.adb
gcc: error trying to exec 'gnat1': execvp: No such file or directory

gnat1可用

sudo find /opt -name "cc1"           
Password:
/opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1
/opt/GNAT/2019/libexec/gcc/x86_64-apple-darwin17.7.0/8.3.1/cc1
/opt/gcc-11.1.0/libexec/gcc/x86_64-apple-darwin15/11.1.0/cc1

同样适用于gnat1

我的路径包括/opt/gnat-ce-2021/bin

你使用的是什么版本的Xcode(或命令行工具)?我有clt

$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 14.1.0.0.1.1666437224
volume: /
location: /
install-time: 1667592295
groups: com.apple.FindSystemFiles.pkg-group

你真的需要14.1.

gnat1, cc1的权限有问题吗?在这个M1 mini上我有

$ ls -l /opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1
-rwxr-xr-x  1 root  wheel  35799072 14 Jun  2021 /opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1

没有你遇到的那种问题;但是,我自己或AdaCore提供的早期gcc存在各种各样的问题,您需要定义SDKROOT,

export SDKROOT=$(xcrun --show-sdk-path)

$ /opt/gnat-ce-2021/bin/gcc hello.c -I$SDKROOT/usr/include -L$SDKROOT/usr/lib

如果你要尝试GCC 12.1,你会得到

$ /opt/gcc-12.1.0/bin/gcc hello.c
<built-in>: error: unknown value '13.0.0' of '-mmacosx-version-min'

…你需要GCC 12.2,它不再有OS主版本的任意上限。


您应该可以从这里下载Alire工具包编译器gnat-x86_64-darwin-12.2.0-1.tar.gz

强烈建议在拆包前这样做:

xattr -d com.apple.quarantine gnat-x86_64-darwin-12.2.0-1.tar.gz

最新更新