gfortran 12.2.0 无法在装有 MacOS Ventura 13.1-arm64 的 M1 Macbook Air 上运行

问题描述 投票:0回答:2

gfortran 无法在装有 MacOS Ventura 13.1-arm64 的 M1 Macbook Air 上运行

当我尝试编译任何程序时,例如

program main
  print *, "Hello world."
end program main

我收到以下错误消息:

(base) BL@MacBook-Air ~ % gfortran hello.f95 -o hello
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

似乎只有gfortran会报错;我可以使用 gcc 编译等效的 C 程序。

我尝试了一些事情:

但这些都没有任何区别。 我安装了最新版本的 Xcode,因此存在命令行工具。

有关我现在设置的一些详细信息:

Xcode 已安装,版本 14.2 (14C18)

(base) BL@MacBook-Air ~ % which gfortran
/usr/local/bin/gfortran
(base) BL@MacBook-Air ~ % which gcc
/usr/bin/gcc
(base) BL@MacBook-Air ~ % which ld
/usr/bin/ld

有人建议添加一个链接,但这又带来了另一个问题:

(base) BL@MacBook-Air ~ % gfortran hello.f95 -o hello -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd

因此,似乎既存在链接问题,又存在缺少对 M1 芯片支持的问题。

关于如何解决这个问题有什么建议吗?

macos arm gfortran
2个回答
0
投票

我开始怀疑我链接的SDK已经过时了。我在磁盘上搜索“SDK”并找到了一个看起来较新的版本。所以我改变了链接:

-L/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib

现在 gfortran 似乎可以按预期编译。


0
投票

返回之前的命令行工具:下载并安装

Command_Line_Tools_for_Xcode_14.3.1.dmg

© www.soinside.com 2019 - 2024. All rights reserved.