Rcpp 找不到 Boost 标头
Rcpp isn't finding Boost headers
我在R包项目中有一个名为src/windows.cpp
的文件(矢量的窗口函数,与MS Windows无关! 文件顶部如下所示:
// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(cpp11)]]
#include <Rcpp.h>
#include <algorithm>
#include <boost/algorithm/string/join.hpp>
using namespace Rcpp;
这似乎不足以让它找到 Boost 标头 - 当我执行devtools::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
添加到DESCRIPTION
文件的Imports:
部分,这是否正确/可取?
您是否按照此处所述将其添加到LinkingTo
?
进一步
请注意,虽然
Rcpp::depends
属性建立依赖项 对于sourceCpp
,重要的是要注意,如果您包含相同的 R 包中的源文件 这些依赖项仍必须列在 文件包DESCRIPTION
的Imports
和/或LinkingTo
字段。 ... 仅提供C++头文件(并且没有共享库)的包只需要使用LinkingTo
引用。
相关文章:
- 错误"Could not find Boost"(缺少:上下文标头)
- 带有 Boost.Beast 的异步读取标头
- boost::hana 转发声明标头的用例是什么?
- 为什么 boost 文件系统和 libpq-fe 标头不会在同一个文件中编译
- 使用 C++11 选项编译 C++98 代码时由于 Boost 标头而导致的不明确重载
- 在Boost标头文件中编译错误.Centos 7失败,在Ubuntu上编译16.04
- 为什么BOOST.PROGROGROGOTIONS不仅仅是标头
- Boost BEAST操纵HTTP响应标头持续接受
- Android Studio 找不到 Boost 标头
- 如何用Boost Beast放置一个定制标头,以供Websocket握手
- 如何根据Boost版本有选择性地包括Boost标头
- Rcpp 找不到 Boost 标头
- 将 Boost 标头包含在 .h 文件中但不包含在.cpp文件中时出错
- CMakeList 不会包含 Boost 标头
- 哪些 Boost 库是仅标头的
- 包含boost::asio标头时引发运行时异常
- 在 CMake 仅标头库中生成,"stores"其对 boost 文件系统的依赖性
- 为什么boost shared_ptr包含带有close()的标头
- boost::atomic的标头是什么
- g++/c++生成文件依赖项以忽略boost标头