c++ - MacOS Big Sur M1 芯片,R devtool monocle3 安装期间出现 cmath 错误

标签 c++ r xcode devtools apple-m1

我正在尝试使用以下方法在 M1 芯片 MacOS Big Sur 11.4 上的 Rstudio(R 版本 4.1.0)中安装 Monocle3 ( here ):

devtools::install_github('cole-trapnell-lab/leidenbase')

我收到此错误消息,这使得 cmath header 看起来不起作用。

clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -DIGRAPH_THREAD_LOCAL=/**/ -DNDEBUG -I. -Icigraph/src -Icigraph/include -Icigraph/src/prpack -Ileidenalg/include -DUSING_R -DPRPACK_IGRAPH_SUPPORT -fPIC  -Wall -g -O2  -c cigraph/src/DensityGrid.cpp -o cigraph/src/DensityGrid.o
In file included from cigraph/src/DensityGrid.cpp:41:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/local/include/math.h:752:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from cigraph/src/DensityGrid.cpp:41:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:738:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from cigraph/src/DensityGrid.cpp:41:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:767:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from cigraph/src/DensityGrid.cpp:41:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make: *** [cigraph/src/DensityGrid.o] Error 1
ERROR: compilation failed for package ‘leidenbase’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/leidenbase’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/37/6b_9y9v11nzftf912bbhbhr00000gn/T//Rtmph3567G/file159343f7bb5fc/leidenbase_0.1.3.tar.gz’ had non-zero exit status
> 

我使用技巧编辑了 ~/.R/Makevars 文件 here将 SDK“重新链接”到 C++ 编译器。仍然无法工作。
我还尝试更新 Xcode、删除并重新下载 Xcode、删除并重新下载 CommandLineTools。

没有任何效果。

这是我当前的 ~/.R/Makevars 文件:

CC=clang
CXX=clang++
CXXFLAGS= -O3 -pedantic -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

提前感谢您的建议或解决方法。

最佳答案

通过将 cmath 文件中的 #include<> 更改为调用 #include<\Full\path\here\to\math.h> 解决了该问题,其中 math.h 与 cmath 位于同一目录中。

关于c++ - MacOS Big Sur M1 芯片,R devtool monocle3 安装期间出现 cmath 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68168291/

相关文章:

c++ - strncpy_s - 缓冲区太小断言

r - 如何在 k 均值中使用欧氏距离以外的不同距离公式

r - 带有两个数据框的ggplot条形图

sql-server - RODBC 错误 : 'Calloc' could not allocate memory

iphone - 呈现模型 View 时Xcode崩溃

c++ - C++中的电子邮件解析器

c++ - 有没有办法告诉程序正在抛出异常?

c++ - std::move() 如何将值传输到 RValues 中?

ios - iTunes 内部测试员通知

iphone - 如何使用不同高度的 UISCrollView 分页?