【问题标题】:"ld: library not found for -lSystem" when installing homebrew ruby on Big Sur在 Big Sur 上安装自制 ruby​​ 时出现“ld: library not found for -lSystem”
【发布时间】:2021-03-04 14:55:04
【问题描述】:

安装 OS11 Big Sur 使我的 ruby​​ 安装不再有效,所以我正在尝试重新安装它。我已经按照说明here 安装了rbenv,并且rbenv-doctor 脚本运行表明没有问题。但是当我尝试运行 rbenv install 2.7.2 时,我收到与我的编译器设置相关的错误:

% rbenv install 2.7.2
Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/yn/wzkl_t8567l9pvwhp0wsm40w0000gn/T/ruby-build.20201121103616.80606.FFBFEn
Results logged to /var/folders/yn/wzkl_t8567l9pvwhp0wsm40w0000gn/T/ruby-build.20201121103616.80606.log

Last 10 log lines:
tool/config.guess already exists
tool/config.sub already exists
checking build system type... x86_64-apple-darwin20.1.0
checking host system type... x86_64-apple-darwin20.1.0
checking target system type... x86_64-apple-darwin20.1.0
checking whether the C compiler works... no
configure: error: in `/var/folders/yn/wzkl_t8567l9pvwhp0wsm40w0000gn/T/ruby-build.20201121103616.80606.FFBFEn/ruby-2.7.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

对应的config.log当然很长,但是相关的行是:

configure:3017: checking for ruby
configure:3035: found /usr/bin/ruby
configure:3048: result: /usr/bin/ruby
configure:3121: checking build system type
configure:3135: result: x86_64-apple-darwin20.1.0
configure:3223: checking host system type
configure:3236: result: x86_64-apple-darwin20.1.0
configure:3256: checking target system type
configure:3269: result: x86_64-apple-darwin20.1.0
configure:4016: checking for C compiler version
configure:4025: clang --version >&5
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /usr/local/clang6/bin
configure:4036: $? = 0
configure:4025: clang -v >&5
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /usr/local/clang6/bin
configure:4036: $? = 0
configure:4025: clang -V >&5
clang-6.0: error: argument to '-V' is missing (expected 1 value)
clang-6.0: error: no input files
configure:4036: $? = 1
configure:4025: clang -qversion >&5
clang-6.0: error: unknown argument: '-qversion'
clang-6.0: error: no input files
configure:4036: $? = 1
configure:4056: checking whether the C compiler works
configure:4078: clang  -I/Users/richard/.rbenv/versions/2.7.2/include -I/usr/local/opt/readline/include -L/Users/richard/.rbenv/versions/2.7.2/lib -L/usr/local/opt/readline/lib conftest.c  >&5
ld: library not found for -lSystem
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4082: $? = 1
configure:4120: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:4125: error: in `/var/folders/yn/wzkl_t8567l9pvwhp0wsm40w0000gn/T/ruby-build.20201121101556.78734.11rqwy/ruby-2.7.2':
configure:4127: error: C compiler cannot create executables
See `config.log' for more details

(主要?)问题似乎是错误:

ld: library not found for -lSystem

...但是之前的错误似乎暗示配置脚本不理解命令行选项...?

以下是有关我的设置的一些相关详细信息:

XCode 命令行工具:

% pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
version: 12.2.0.0.1.1604076827

gcc:

% which gcc
/usr/bin/gcc
% gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

叮当声:

% which clang
/usr/local/clang6/bin/clang
% clang -v
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /usr/local/clang6/bin

我的.zprofile中也有以下内容,以解决之前没有找到必要的头文件的问题:

export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

提前感谢您的任何见解。

【问题讨论】:

  • 也打这个。
  • 嗨@richarddmorey,你解决了这个问题吗?
  • @MartinFink nope...打算赏金。

标签: ruby macos homebrew rbenv


【解决方案1】:

如果有可能使用rvm,我能够在MacOS Big Sur

上成功安装2.7.2 版本

安装命令输出在此处捕获https://gist.github.com/gowtham1984/ba04219aa03dd29e5d44d48164c15c7a

【讨论】:

    【解决方案2】:

    问题似乎是您使用的是clang6(可能来自https://cran.r-project.org/bin/macosx/tools/)而不是Xcode 命令行工具附带的clang 版本。你需要苹果版的clang

    验证您是否已使用sudo xcode-select --install 安装了 CLT。安装后验证/usr/bin/clang -v 返回类似Apple clang version 12 的内容。现在修改您的$PATH 并重试:

    export PATH=/usr/bin:$PATH
    rbenv install 2.7.2
    

    或者使用您喜欢的任何其他 shell 技巧来获取 Apple 版本的 clang 以供 rbenv 使用,然后重试安装。

    【讨论】:

    • 刚刚尝试过,确实取得了进展,但现在我看到“compile.c:9859:63: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'”。啊!
    • 那么this 可能会有所帮助。
    • 先试过了;不幸的是,没有效果。
    猜你喜欢
    • 2021-09-21
    • 2021-03-27
    • 1970-01-01
    • 2016-07-02
    • 2015-06-15
    • 2013-11-08
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    相关资源
    最近更新 更多