RCPP找不到Boost标头

肯·威廉姆斯

src/windows.cpp在R包项目中有一个名为(矢量的窗口功能,与MS Windows无关!)的文件。文件的顶部如下所示:

// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(cpp11)]]

#include <Rcpp.h>
#include <algorithm>
#include <boost/algorithm/string/join.hpp>

using namespace Rcpp;

这似乎不足以让它找到Boost头-当我执行adevtools::load_all(.)来触发编译时,我看到此构建失败:

* installing *source* package ‘MyPackage’ ...
** libs
g++ -m64  -I/usr/include/R -DNDEBUG  -I"/home/rstudio/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" 
-I/usr/local/include  -std=c++11 -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c windows.cpp -o windows.o
windows.cpp:6:43: fatal error: boost/algorithm/string/join.hpp: No such file or directory
 #include <boost/algorithm/string/join.hpp>
                                           ^
compilation terminated.

我已经BH安装好了,并且出现了相关的标题:

> .libPaths()[1]
[1] "/home/rstudio/R/x86_64-redhat-linux-gnu-library/3.4"

> dir(file.path(.libPaths()[1], 'BH/include/boost/algorithm/string'))
 [1] "case_conv.hpp"             "classification.hpp"        "compare.hpp"              
 [4] "concept.hpp"               "config.hpp"                "constants.hpp"            
 [7] "detail"                    "erase.hpp"                 "find_format.hpp"          
[10] "find_iterator.hpp"         "find.hpp"                  "finder.hpp"               
[13] "formatter.hpp"             "iter_find.hpp"             "join.hpp"                 
[16] "predicate_facade.hpp"      "predicate.hpp"             "regex_find_format.hpp"    
[19] "regex.hpp"                 "replace.hpp"               "sequence_traits.hpp"      
[22] "split.hpp"                 "std"                       "std_containers_traits.hpp"
[25] "trim_all.hpp"              "trim.hpp"                  "yes_no_type.hpp"   

看来核心问题是该[[Rcpp::depends(BH)]]指令未将相关的Boost目录添加到编译器指令中,对吧?我应该在设置中寻找可能导致此问题的什么?

我已添加BH文件的这一Imports:部分DESCRIPTION,是正确的还是建议的?

本杰明·克里斯托弗森

您是否已将其添加到此处LinkingTo提到的位置

此外

请注意,尽管该Rcpp::depends属性为建立了依赖关系sourceCpp,但要特别注意的是,如果在R包中包含相同的源文件,则这些依赖关系仍必须在文件Imports和/或LinkingTo字段中列出DESCRIPTION...仅提供C ++头文件(而不提供共享库)的软件包仅需使用引用LinkingTo

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章