提问人:hishikatakanari 提问时间:11/16/2023 最后编辑:Philhishikatakanari 更新时间:11/16/2023 访问量:47
使用 Rcpp 编译库会导致许多“未知类型”/“未命名成员”错误
Compiling a library with Rcpp causing many 'unknown type'/'no member named' errors
问:
我正在尝试编译一个包含 Rcpp 函数的包,但编译发现了很多错误:
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source polowam
* installing to library ‘/Users/hkanari/Library/R/arm64/4.3/library’
* installing *source* package ‘polowam’ ...
** using staged installation
** libs
using C++ compiler: ‘clang version 14.0.6’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
using SDK: ‘’
In file included from RcppExports.cpp:4:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/RcppCommon.h:30:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/cmath:317:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:316:
/Users/hkanari/anaconda3/bin/../include/c++/v1/stdlib.h:150:34: error: unknown type name 'ldiv_t'
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/stdlib.h:151:12: error: no member named 'ldiv' in the global namespace
return ::ldiv(__x, __y);
~~^
/Users/hkanari/anaconda3/bin/../include/c++/v1/stdlib.h:154:34: error: unknown type name 'lldiv_t'
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/stdlib.h:156:12: error: no member named 'lldiv' in the global namespace
return ::lldiv(__x, __y);
~~^
In file included from RcppExports.cpp:4:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/RcppCommon.h:30:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/cmath:317:
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:388:31: error: use of undeclared identifier 'FP_NAN'
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:388:39: error: use of undeclared identifier 'FP_INFINITE'
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:388:52: error: use of undeclared identifier 'FP_NORMAL'
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:388:63: error: use of undeclared identifier 'FP_SUBNORMAL'
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:388:77: error: use of undeclared identifier 'FP_ZERO'
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:393:21: error: use of undeclared identifier 'FP_ZERO'
return __x == 0 ? FP_ZERO : FP_NORMAL;
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/math.h:393:31: error: use of undeclared identifier 'FP_NORMAL'
return __x == 0 ? FP_ZERO : FP_NORMAL;
^
In file included from RcppExports.cpp:4:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/RcppCommon.h:30:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/platform/compiler.h:153:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/unordered_map:523:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__hash_table:19:
/Users/hkanari/anaconda3/bin/../include/c++/v1/__functional/hash.h:43:12: error: reference to unresolved using declaration
_VSTD::memcpy(&__r, __p, sizeof(__r));
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/cstring:80:1: note: using declaration annotated with 'using_if_exists' here
using ::memcpy _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:4:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/RcppCommon.h:30:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/platform/compiler.h:153:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/unordered_map:523:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__hash_table:22:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__memory/allocator_traits.h:14:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__memory/construct_at.h:23:
/Users/hkanari/anaconda3/bin/../include/c++/v1/new:355:14: error: no member named 'aligned_alloc' in the global namespace
return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
~~^
/Users/hkanari/anaconda3/bin/../include/c++/v1/new:369:5: error: no type named 'free' in the global namespace
::free(__ptr);
~~^
In file included from RcppExports.cpp:4:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/RcppCommon.h:30:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Users/hkanari/Library/R/arm64/4.3/library/Rcpp/include/Rcpp/platform/compiler.h:153:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/unordered_map:528:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__memory/allocator.h:23:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/stdexcept:48:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/iosfwd:100:
In file included from /Users/hkanari/anaconda3/bin/../include/c++/v1/__mbstate_t.h:29:
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:143:77: error: use of undeclared identifier 'wcschr'
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:150:87: error: use of undeclared identifier 'wcspbrk'
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:157:78: error: use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:145:16: note: 'wcschr' declared here
const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:164:86: error: use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:147:16: note: 'wcschr' declared here
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:164:86: error: no matching function for call to 'wcschr'
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Users/hkanari/anaconda3/bin/../include/c++/v1/wchar.h:147:16: note: candidate disabled: <no message provided>
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [/Library/Frameworks/R.framework/Resources/etc/Makeconf:198: RcppExports.o] Error 1
ERROR: compilation failed for package ‘polowam’
* removing ‘/Users/hkanari/Library/R/arm64/4.3/library/polowam’
* restoring previous ‘/Users/hkanari/Library/R/arm64/4.3/library/polowam’
Exited with status 1.
这些错误似乎源自标准的 C++ 库/实用程序,所以我对导致这种情况的原因感到困惑。
我使用的是装有 macOS Ventura 2 的 M13.4 Mac mini。
关于可能出什么问题的任何想法?
我尝试将我的软件包与其他使用 Rcpp 的软件包进行比较,以尝试找到我缺少的任何内容以在我的软件包中使用 Rcpp,但没有成功找到任何新内容。
我还尝试使用 Rcpp.package.skeleton() 使用 Rcpp 创建一个骨架 R 包,虽然它确实被创建了,但由于同样的错误,它也无法编译。
在包的上下文之外,我能够毫无问题地使用 Rcpp(例如带有 Rcpp::cpp函数)。
答: 暂无答案
评论