我刚刚更新到OSX10.14.6 (Mojave),现在,在升级Xcode和移植MacPorts之后,即使是最简单的C程序也不能连接到任何gcc版本。例如,链接程序
int main() {}提供:
dcs16> gcc test.c
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status我在/opt/local/bin中使用的是gcc 6.5:
dcs16> gcc --version
gcc (MacPorts gcc6 6.5.0_4) 6.5.0Xcode的版本是11.0,我已经安装了这个包(推荐用来解决其他人遇到的一些编译问题):
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg任何帮助都是非常感谢的。
注意:使用clang链接没有问题。
注: gcc搜索目录如下:
test> gcc -print-search-dirs
install: /opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/
programs: =/opt/local/libexec/gcc/x86_64-apple-darwin18/6.5.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/6.5.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../../../x86_64-apple-darwin18/bin/x86_64-apple-darwin18/6.5.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../../../x86_64-apple-darwin18/bin/
libraries: =/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../../../x86_64-apple-darwin18/lib/x86_64-apple-darwin18/6.5.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../../../x86_64-apple-darwin18/lib/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../x86_64-apple-darwin18/6.5.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin18/6.5.0/../../../发布于 2019-09-24 21:55:07
添加"-L/usr/lib“可以解决这个问题。
另外,从Xcode11.0到Xcode10.3的降级也解决了这个问题!注意:我还检查了刚刚发布的Xcode11.1,但问题仍然存在于11.1中。
补充说明:另一位程序员告诉我,升级到OSX 10.15可以解决这个问题。所以这是OSX 10.14和Xcode 11之间的不兼容。
添加了28/12/2020,另一个程序员告诉我,他在使用Xcode12.3时遇到了这个问题。他的解决方案是降级到12.2。
https://stackoverflow.com/questions/58072318
复制相似问题