rcpp - Rcpp 属性是否支持仅非标头的 Rcpp 模块库?
问题描述
如果我做:
Rcpp::Rcpp.package.skeleton("test1", module = TRUE)
Rcpp::Rcpp.package.skeleton("test2")
然后在test1
包src
目录中,我只保留两个文件:
// rcpp_module.cpp
#include <Rcpp.h>
#include "rcpp_module.h"
std::string World::greet(){ return msg; }
RCPP_MODULE(yada){
using namespace Rcpp ;
class_<World>("World")
.constructor() // expose the default constructor
.method("greet", &World::greet , "get the message")
.method("set", &World::set , "set the message")
;
}
和
// rcpp_module.h
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]
class World {
public:
World() : msg("hello") {}
void set(std::string msg) { this->msg = msg; }
std::string greet(); // NOTE this is just the declaration
private:
std::string msg;
};
加上单个loadModule
调用:
# zzz.R
loadModule("yada", TRUE)
然后,在test2
package中src
,我有一个文件:
// rcpp_hello_world.cpp
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::depends(test1)]]
#include "rcpp_module.h"
// [[Rcpp::export]]
List rcpp_hello_world2(SEXP xptr) {
Rcpp::XPtr<World> world_ptr(xptr);
Rcout << world_ptr->greet() << std::endl;
return List::create();
}
test2
在和下都有test1
它的描述。我也将's复制到目录。然而,当我尝试使用时收到一个未定义的符号:Depends:
LinkingTo:
test1
rcpp_module.h
inst/include
test2
Error in dyn.load(dllfile) :
unable to load shared object 'test2/src/test2.so':
dlopen(test2/src/test2.so, 6): Symbol not found: __ZN5World5greetEv
我究竟做错了什么?
解决方案
推荐阅读
- r - R(cov.wt)中的加权协方差似乎无法正常工作
- php - Benchmark api返回序列化数组但无法在php中转换为反序列化
- android - NotifyListeners 不会在颤动中重建小部件
- wpf - 如果相邻元素填充容器内的空间(DockPanel,Grid),则 WPF 画布作为按钮内的内容不可见
- c# - 带有可变循环的所有组合
- c# - 为什么我的 PowerShell 脚本在 C# 应用程序中不起作用?
- c# - 收集数据(从 frm1 调用一个收集器方法到 frm2)
- python - Python/Numpy - 新数组中简单线性回归的返回斜率
- youtube-data-api - GSuite API 凭据上的品牌 YouTube 频道出现 403 org_internal 错误
- java - 从字符串中删除自定义标签,然后格式化其内容