下面是我尝试安装Ruby2.2时得到的信息:
$ ruby-install ruby 2.2.10
# ...
>>> Compiling ruby 2.2.10 ...
CC = clang
LD = ld
LDSHARED = clang -dynamic -bundle
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -I/opt/X11/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin19 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -fstack-protector -Wl,-u,_objc_msgSend -Wl,-pie -framework CoreFoundation
SOLIBS = -lgmp
Apple clang version 12.0.0 (clang-1200.0.31.1)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
translating probes probes.d
. ./vm_opts.h
file2lastrev.rb: does not seem to be under a vcs: .
make: [.revision.time] Error 1 (ignored)
./revision.h unchanged
compiling main.c
compiling dmydln.c
compiling miniinit.c
compiling miniprelude.c
compiling array.c
compiling bignum.c
compiling class.c
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling encoding.c
encoding.c:825:2: error: implicit declaration of function 'rb_str_change_terminator_length' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_str_change_terminator_length(obj, oldtermlen, termlen);
^
1 error generated.
make: *** [encoding.o] Error 1
!!! Compiling ruby 2.2.10 failed!10.15.6
关于如何调试或修复这个问题,有什么想法吗?在升级我的操作系统之前,我以前能够安装2.2的其他版本。我也可以在没有问题的情况下安装Ruby2.7之类的后续版本
发布于 2020-10-20 23:57:48
在我意识到这个错误与使用macOS的GCC编译有关之后,我决定做一个测试。
因为Ruby的旧版本需要在更新的make中不再存在的指令,所以有必要下载用于Xcode的命令行工具的旧版本。
首先,使用以下方法删除实际版本:
sudo rm -rf /Library/Developer/CommandLineTools
忽略有关丢失git的错误。
转到https://developer.apple.com/download/more/并下载11.x版本的Xcode命令行工具。
我下载了11.5版本,它成功了。运行gcc -v时返回的
Configured with: --prefix = / Library / Developer / CommandLineTools / usr --with-gxx-include-dir = / Library / Developer / CommandLineTools / SDKs / MacOSX.sdk / usr / include / c ++ / 4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: / Library / Developer / CommandLineTools / usr / bin要与最近的命令行12.x进行比较,您将看到如下内容:
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.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin发布于 2021-05-18 10:40:59
显然,忽略编译器警告也是一个选项。
export optflags="-Wno-error=implicit-function-declaration"关于进一步的座垫,见Problem when installing Ruby 2.2.9 on Mac Big Sur M1
发布于 2020-10-10 19:34:49
我能够使用rvm在Mac10.15.7上安装该版本。
我已经安装了openssl@1.1和自制软件。如果你运行brew info openssl,你会看到什么?我会先试试brew upgrade openssl。
尝试使用信息brew返回运行export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"。那就试试rvm install 2.2.10。如果这不起作用,我会尝试rvm install 2.2.10 --with-openssl-dir=/usr/local/opt/openssl --with-openssl-lib=/usr/local/opt/openssl/lib --with-openssl-include=/usr/local/opt/openssl/include,只需确保这些路径对您的系统是正确的。
您可能还需要运行
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
事先,将由brew info提供。
https://stackoverflow.com/questions/63926460
复制相似问题