在OSX Catalina上使用C++和gems时遇到的问题

6

我正在尝试使用以下命令安装一个新的gem:

gem install sassc

但是它无法应对C++问题:

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/ext
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0 -r ./siteconf20191127-10955-52fjdl.rb extconf.rb
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/ext
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/ext
make "DESTDIR="
compiling ./libsass/src/units.cpp
In file included from ./libsass/src/units.cpp:3:
In file included from ./libsass/src/units.hpp:4:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:314:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:315:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:316:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from ./libsass/src/units.cpp:3:
In file included from ./libsass/src/units.hpp:4:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:728:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/units.cpp:3:
In file included from ./libsass/src/units.hpp:4:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:757:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/units.cpp:3:
In file included from ./libsass/src/units.hpp:4:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make: *** [units.o] Error 1

make failed, exit code 2

我尝试了SO上找到的一切,但目前为止都没有帮助


我正在使用 Ruby 2.6.5(与您一样),并成功安装了 sassc-2.2.1.gem。我已经安装了 Xcode 11.2.1。 - Eljay
这里也一样,我怀疑我的机器配置出了问题 :/ - viplezer
你的工具链出了很大问题。你尝试过重新安装它吗? - Lightness Races in Orbit
我重新安装了Xcode和命令行工具,但目前为止还没有任何帮助。 - viplezer
我在我的 /usr/local/include 文件夹中发现了一些奇怪的符号链接。我将它们全部删除后,问题似乎已经解决了。 - viplezer
2个回答

6

我在Swift论坛上找到了解决方案,对我有效。看起来命令行工具已经损坏或过时。

TL;DR;

  1. 删除CommandLine Tools目录:sudo rm -rf /Library/Developer/CommandLineTools
  2. 重新创建: sudo xcode-select -s /Applications/Xcode.app

我尝试了很多方法,这个对我有效。而且只需要2秒钟。 - new name
我收到以下错误信息:xcode-select: error: invalid developer directory '/Applications/Xcode.app' - micahbf

5
原来我在/usr/local/include文件夹中有一堆奇怪的符号链接。 我删除了整个文件夹,重新安装Homebrew,一切又恢复正常了。

谢谢!这也解决了我非 Ruby/C++ Conan 依赖构建问题。 - scrrr

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接