Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带Rcpp的R包 我尝试用C++ < Rcpp >代码>在我的R包中添加一个小的C++函数(称为代码>还原字符串< /COD>),但是我没有配置包,所以它编译得很好。你可以找到包裹_C++_R_Package_Rcpp - Fatal编程技术网

带Rcpp的R包 我尝试用C++ < Rcpp >代码>在我的R包中添加一个小的C++函数(称为代码>还原字符串< /COD>),但是我没有配置包,所以它编译得很好。你可以找到包裹

带Rcpp的R包 我尝试用C++ < Rcpp >代码>在我的R包中添加一个小的C++函数(称为代码>还原字符串< /COD>),但是我没有配置包,所以它编译得很好。你可以找到包裹,c++,r,package,rcpp,C++,R,Package,Rcpp,下面是错误消息的一部分 Error: package or namespace load failed for ‘SimBitWrapper’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/SimBitWrapper/libs/SimBitWrapper.so': d

下面是错误消息的一部分

Error: package or namespace load failed for ‘SimBitWrapper’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/SimBitWrapper/libs/SimBitWrapper.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/SimBitWrapper/libs/SimBitWrapper.so, 6): Symbol not found: __Z12reduceStringv
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/SimBitWrapper/libs/SimBitWrapper.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.5/Resources/library/SimBitWrapper/libs/SimBitWrapper.so
我试图一次又一次地修改
名称空间
描述
文件以及
src/RcppExports.cpp
R/RcppExports.R
文件,但我无法解决问题。以下是这些文件以及
reduceString.cpp
文件

名称空间

useDynLib(SimBitWrapper, .registration=TRUE)
exportPattern("^[^\\.]")
importFrom(Rcpp, evalCpp)
描述

Package: SimBitWrapper
Title: R wrapper for SimBit
Version: 5.1.0
Authors@R: 
    person(given = "Remi",
           family = "Matthey-Doret",
           role = c("aut", "cre"),
           email = "remi.b.md@gmail.com",
           comment = c(ORCID = "0000-0001-5614-5629"))
Description: The package is a wrapper for SimBit (SimBit is a simulation platform for evolutionary genetic studies). Please see the SimBit manual (at https://github.com/RemiMattheyDoret/SimBit) for description of how to use this SimBitWrapper package.
License: MIT
Encoding: UTF-8
LazyData: true
Depends: R (>= 2.15)
Imports: data.table, processx, Rcpp
LinkingTo: Rcpp
Suggests:
URL: https://github.com/RemiMattheyDoret
src/RcppExports.cpp

#include <Rcpp.h>

using namespace Rcpp;

// reduceString
std::string reduceString();
RcppExport SEXP _SimBitWrapper_reduceString() {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    rcpp_result_gen = Rcpp::wrap(reduceString());
    return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
    {"_SimBitWrapper_reduceString", (DL_FUNC) &_SimBitWrapper_reduceString, 0},
    {NULL, NULL, 0}
};

RcppExport void R_init_SimBitWrapper(DllInfo *dll) {
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
    R_useDynamicSymbols(dll, FALSE);
}
#包括
使用名称空间Rcpp;
//减少开支
std::string reduceString();
RcppExport SEXP\u SimBitWrapper\u reduceString(){
开始
Rcpp::RObject Rcpp\u结果\u gen;
Rcpp::RNGScope Rcpp\u RNGScope\u gen;
rcpp_result_gen=rcpp::wrap(reduceString());
返回rcpp\u结果\u gen;
结束(RCPP)
}
静态常量R_CallMethodDef CallEntries[]={
{u SimBitWrapper\u reduceString',(DL_FUNC)和{u SimBitWrapper\u reduceString,0},
{NULL,NULL,0}
};
RcppExport void R_init_SimBitWrapper(DllInfo*dll){
R_注册表例程(dll,NULL,CallEntries,NULL,NULL);
R_使用动态符号(dll,FALSE);
}
R/RcppExports.R

reduceString <- function(x) {
    .Call(`_SimBitWrapper_reduceString`,x)
}

reduceString感谢您发布了回购协议的链接

当我使用我(当前)版本的
Rcpp
重新创建
RcppExports.{cpp,R}
并调用
compileAttributes()
时,它就对我起了作用。您有什么版本的
Rcpp

下面的日志使用了littler的包装,但这并不重要。
R CMD…
命令也会以同样的方式工作

日志
edd@rob:/tmp/SimBitWrapper(主)$build.r
*正在检查文件“./DESCRIPTION”。。。好啊
*正在准备“SimBitWrapper”:
*正在检查描述元信息。。。好啊
*清洗钢骨混凝土
*检查源代码和make文件以及shell脚本中的LF行结尾
*检查空目录或不需要的目录
*正在构建“SimBitWrapper_5.1.0.tar.gz”
edd@rob:/tmp/SimBitWrapper(主)$install2.r-l/tmp/lib SimBitWrapper_5.1.0.tar.gz
*正在安装*source*包“SimBitWrapper”。。。
**使用分阶段安装
**自由基
ccache g++-I”/usr/share/R/include“-DNDEBUG-I'/usr/local/lib/R/site library/Rcpp/include'-fpic-g-O3-墙-管道-pedantic-c RcppExports.cpp-o RcppExports.o
ccache g++-I“/usr/share/R/include“-DNDEBUG-I'/usr/local/lib/R/site library/Rcpp/include'-fpic-g-O3-墙-管道-pedantic-c reduceString.cpp-o reduceString.o
reduceString.cpp:在函数“std::string reduceString(Rcpp::CharacterVector&)”中:
reduceString.cpp:10:27:警告:比较不同符号的整数表达式:'size_t'{aka'long unsigned int'}和'R_xlen_t'{aka'long int'}[-Wsign compare]
10 |用于(尺寸i=0;i
差异
edd@rob:/tmp/SimBitWrapper(主)$git diff
diff—git a/R/RcppExports.R b/R/RcppExports.R
索引19a82b4..62f890a 100644
---a/R/RcppExports.R
+++b/R/RcppExports.R
@@ -2,6 +2,6 @@
#发电机令牌:10BE3573-1514-4C36-9D1C-5A225CD40393
reduceString::类型x(xSEXP);
+rcpp_result_gen=rcpp::wrap(reduceString(x));
返回rcpp\u结果\u gen;
结束(RCPP)
}
静态常量R_CallMethodDef CallEntries[]={
-{u SimBitWrapper\u reduceString',(DL_FUNC)和{u SimBitWrapper\u reduceString,0},
+{u SimBitWrapper\u reduceString',(DL_FUNC)和{u SimBitWrapper\u reduceString,1},
{NULL,NULL,0}
};
edd@rob:/tmp/SimBitWrapper(主)$

附言:您的回购协议中有您的第二份套餐。我只是一个顶级的。此外,您还提交了mac电脑中的
.DS\u Store
文件,这些文件对R或回购没有任何用处。

感谢您发布了一个到回购的链接

当我使用我(当前)版本的
Rcpp
重新创建
RcppExports.{cpp,R}
并调用
compileAttributes()
时,它就对我起了作用。您有什么版本的
Rcpp

下面的日志使用了littler的包装,但这并不重要。
R CMD…
命令也会以同样的方式工作

日志
edd@rob:/tmp/SimBitWrapper(主)$build.r
*正在检查文件“./DESCRIPTION”。。。好啊
*正在准备“SimBitWrapper”:
*正在检查描述元信息。。。好啊
*清洗钢骨混凝土
*检查源代码和make文件以及shell脚本中的LF行结尾
*检查空目录或不需要的目录
*正在构建“SimBitWrapper_5.1.0.tar.gz”
edd@rob:/tmp/SimBitWrapper(主)$install2.r-l/tmp/lib SimBitWrapper_5.1.0.tar.gz
*正在安装*source*包“SimBitWrapper”。。。
**使用分阶段安装
**自由基
ccache g++-I”/usr/share/R/include“-DNDEBUG-I'/usr/local/lib/R/site library/Rcpp/include'-fpic-g-O3-墙-管道-pedantic-c RcppExports.cpp-o RcppExports.o
ccache g++-I“/usr/share/R/include“-DNDEBUG-I'/usr/local/lib/R/site library/Rcpp/include'-fpic-g-O3-墙-管道-pedantic-c reduceString.cpp-o reduceString.o
reduceString.cpp:在函数“std::string reduceString(Rcpp::CharacterVector&)”中:
减少限制。cpp:10:27:警告:compa
reduceString <- function(x) {
    .Call(`_SimBitWrapper_reduceString`,x)
}
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
std::string reduceString(CharacterVector& x)
{
    // I cut off this part that does not need to be printed here
}
edd@rob:/tmp/SimBitWrapper(master)$ build.r 
* checking for file ‘./DESCRIPTION’ ... OK
* preparing ‘SimBitWrapper’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘SimBitWrapper_5.1.0.tar.gz’

edd@rob:/tmp/SimBitWrapper(master)$ install2.r -l /tmp/lib SimBitWrapper_5.1.0.tar.gz 
* installing *source* package ‘SimBitWrapper’ ...
** using staged installation
** libs
ccache g++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'    -fpic  -g -O3 -Wall -pipe -pedantic  -c RcppExports.cpp -o RcppExports.o
ccache g++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'    -fpic  -g -O3 -Wall -pipe -pedantic  -c reduceString.cpp -o reduceString.o
reduceString.cpp: In function ‘std::string reduceString(Rcpp::CharacterVector&)’:
reduceString.cpp:10:27: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘R_xlen_t’ {aka ‘long int’} [-Wsign-compare]
   10 |     for (size_t i = 0 ; i < x.size() ; ++i)
      |                         ~~^~~~~~~~~~
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o SimBitWrapper.so RcppExports.o reduceString.o -L/usr/lib/R/lib -lR
installing to /tmp/lib/00LOCK-SimBitWrapper/00new/SimBitWrapper/libs
** R
** byte-compile and prepare package for lazy loading
** help
No man pages found in package  ‘SimBitWrapper’ 
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (SimBitWrapper)
edd@rob:/tmp/SimBitWrapper(master)$ 
edd@rob:/tmp/SimBitWrapper(master)$ git diff
diff --git a/R/RcppExports.R b/R/RcppExports.R
index 19a82b4..62f890a 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -2,6 +2,6 @@
 # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
 
 reduceString <- function(x) {
-    .Call(`_SimBitWrapper_reduceString`,x)
+    .Call(`_SimBitWrapper_reduceString`, x)
 }
 
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index 90dda3b..0b91977 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -6,18 +6,19 @@
 using namespace Rcpp;
 
 // reduceString
-std::string reduceString();
-RcppExport SEXP _SimBitWrapper_reduceString() {
+std::string reduceString(CharacterVector& x);
+RcppExport SEXP _SimBitWrapper_reduceString(SEXP xSEXP) {
 BEGIN_RCPP
     Rcpp::RObject rcpp_result_gen;
     Rcpp::RNGScope rcpp_rngScope_gen;
-    rcpp_result_gen = Rcpp::wrap(reduceString());
+    Rcpp::traits::input_parameter< CharacterVector& >::type x(xSEXP);
+    rcpp_result_gen = Rcpp::wrap(reduceString(x));
     return rcpp_result_gen;
 END_RCPP
 }
 
 static const R_CallMethodDef CallEntries[] = {
-    {"_SimBitWrapper_reduceString", (DL_FUNC) &_SimBitWrapper_reduceString, 0},
+    {"_SimBitWrapper_reduceString", (DL_FUNC) &_SimBitWrapper_reduceString, 1},
     {NULL, NULL, 0}
 };
 
edd@rob:/tmp/SimBitWrapper(master)$