如何在 MacOS Catalina 上使用 gcc 安装 Nokogiri
How to install Nokogiri using gcc on MacOS Catalina
我正在尝试在我的 MacOS Catalina 10.15.1 系统上安装 Nokogiri。
gem install nokogiri
日志文件中的错误是:
"gcc -o conftest -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/x86_64-darwin18 -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/ruby/backward -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0 -I. -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c -L. -L/Users/shairyar/.rvm/rubies/ruby-2.6.3/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L. -L/usr/local/opt/readline/lib -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -lruby.2.6 "
gcc: error: unrecognized command line option '-Wdivision-by-zero'; did you mean '-Wdiv-by-zero'?
gcc: error: unrecognized command line option '-Wshorten-64-to-32'
gcc: error: unrecognized command line option '-Wextra-tokens'; did you mean '-Wextra-semi'?
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
我一直在搜索并尝试使用 brew install gcc
和 brew link gcc
安装 gcc,但这没有帮助。
这是我的 gcc 版本:
$which gcc
/usr/local/bin/gcc
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../gcc-9.2.0/configure --build=x86_64-apple-darwin19 --disable-nls --enable-checking=release --with-system-zlib --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk --enable-languages=c,c++,fortran --with-gmp=/usr/local --with-mpc=/usr/local --with-mpfr=/usr/local
Thread model: posix
gcc version 9.2.0 (GCC)
我也尝试了以下方法,但没有用:
gem install nokogiri -- --use-system-libraries
CC=llvm-gcc gem install nokogiri
为了解决这个问题,我删除了我安装的位于 /usr/local/bin/gcc
的 gcc,这似乎解决了我的问题。当我 运行 命令
which gcc
我得到的输出是:
/usr/local/bin/gcc
我需要 Apple 安装在 /usr/bin/gcc
的那个。
我正在尝试在我的 MacOS Catalina 10.15.1 系统上安装 Nokogiri。
gem install nokogiri
日志文件中的错误是:
"gcc -o conftest -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/x86_64-darwin18 -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/ruby/backward -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0 -I. -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c -L. -L/Users/shairyar/.rvm/rubies/ruby-2.6.3/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L. -L/usr/local/opt/readline/lib -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -lruby.2.6 "
gcc: error: unrecognized command line option '-Wdivision-by-zero'; did you mean '-Wdiv-by-zero'?
gcc: error: unrecognized command line option '-Wshorten-64-to-32'
gcc: error: unrecognized command line option '-Wextra-tokens'; did you mean '-Wextra-semi'?
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
我一直在搜索并尝试使用 brew install gcc
和 brew link gcc
安装 gcc,但这没有帮助。
这是我的 gcc 版本:
$which gcc
/usr/local/bin/gcc
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../gcc-9.2.0/configure --build=x86_64-apple-darwin19 --disable-nls --enable-checking=release --with-system-zlib --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk --enable-languages=c,c++,fortran --with-gmp=/usr/local --with-mpc=/usr/local --with-mpfr=/usr/local
Thread model: posix
gcc version 9.2.0 (GCC)
我也尝试了以下方法,但没有用:
gem install nokogiri -- --use-system-libraries
CC=llvm-gcc gem install nokogiri
为了解决这个问题,我删除了我安装的位于 /usr/local/bin/gcc
的 gcc,这似乎解决了我的问题。当我 运行 命令
which gcc
我得到的输出是:
/usr/local/bin/gcc
我需要 Apple 安装在 /usr/bin/gcc
的那个。