gpt4 book ai didi

r - 在 MacOS/CRAN 上构建 R 包时包含 boost tokenizer.hpp 文件时出错

转载 作者:行者123 更新时间:2023-12-04 07:19:55 26 4
gpt4 key购买 nike

由于包含 boost 库时出现特定错误,我在将 R 包发布到 CRAN 时遇到了问题。我在包中的一个 .cpp 文件的顶部是

#include <Rcpp.h>
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <omp.h>
#include <vector>

// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(openmp)]]
在 MacOS 上运行检查时(通过 rhub::check(platform = "macos-highsierra-release-cran") ,我收到以下错误:

In file included from wgt_jaccard.cpp:6:/Users/user2suimGYX/R/BH/include/boost/tokenizer.hpp:63:9: error: field of type 'std::_1::wrap_iter<const char *>' has private constructor: first(c.begin()), last(c.end()), f(f) { }^


wgt_jaccard.cpp:117:19: note: in instantiation of function template specialization 'boost::tokenizer<boost::char_separator<char, std::__1::char_traits >, std::__1::__wrap_iter<const char *>, std::__1::basic_string ::tokenizer<Rcpp::internal::string_proxy<16, PreserveStorage> >' requested heretokenizer tokens(y(i), sep);^


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1420:31: note: declared private here_LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}^


我的 Makevars 文件的内容是
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) -DBOOST_NO_AUTO_PTR
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS)
CXX_STD = CXX11
我试过四处搜索,但找不到关于此错误的太多信息。完整包位于 here .任何帮助深表感谢。

最佳答案

相对于 the repo您好心提供,我们发现需要进行两项更改:
首先,没有(无条件)有一个 #include <omp.h>因为 OpenMP 可以是可选的,尤其是。在 macOS 上。一个简单的#ifdef OPENMP做这项工作。
其次,(可以说几乎无法理解)编译器消息与 tokenizer 的 Boost 类型/类有关。对您通过直接从 Rcpp::CharacterVector 建立索引而提供的 Rcpp 对象感到困惑。 .去过那里,这样做 - 更保守的方法是首先分配给 std::string然后把它传递下去。
通过这两个更改,一切都变得更好了,它可以在 clang++ 下的 macOS 上编译以及。
(现在已合并,谢谢)PR #2有血腥的细节,但很短。

关于r - 在 MacOS/CRAN 上构建 R 包时包含 boost tokenizer.hpp 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68567416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com