带有Rcpp的R Cran软件包构建在除Solaris之外的所有系统上



我正在处理一个提交给CRAN的R库,它在除Solaris之外的所有平台上编译。多亏了R-hub构建器网站,我能够在该系统上获得两种不同类型的错误(否则我无法访问任何Solaris机器(。

然而,我不知道我犯了什么错误。此外,两个编译器的行为大不相同:

  1. 使用选项:;Oracle Solaris 10,x86,32位,R发行版";,我的代码编译了,但它在运行时崩溃;segfault";。

  2. 使用选项:";Oracle Solaris 10,x86,32位,R发行版,Oracle Developer Studio 12.6〃;,代码甚至没有编译,得到了一个奇怪的错误:

"模块.cpp";,第340行:错误:name函数不明确,void Rcpp::function<RESULT_TYPE>(const char*,RESULT_TYPE((((,const char(和std::function&lt_签名&gt;。

由于该包在Windows、Ubuntu、CentOs、Mac OS X上编译(没有任何警告(并执行,但我不知道应该查找哪些可能的错误。

其他人也有同样的问题吗?你有什么提示吗?

感谢您的支持。

更新日期:2021年4月30日:我已经为系统Oracle Solaris 10,x86,32位,R-release,Oracle Developer Studio 12.6的R-hub构建器制定了一个复制错误的最小示例。结果可在此处获得。

在rcpp_module.cpp文件中,我们有:

#include <Rcpp.h>
#include "KWD_Histogram2D.h"
Rcpp::List compareAll(Rcpp::NumericMatrix Coordinates,  // This is line 49
Rcpp::NumericMatrix Weights, int L = 3,
bool recode = true, const std::string& method = "approx",
const std::string& algorithm = "colgen",
const std::string& model = "mincostflow",
const std::string& verbosity = "silent",
double timelimit = 14400, double opt_tolerance = 1e-06,
bool unbalanced = false, double unbal_cost = 1e+09,
bool convex = true) {
Rcpp::List sol;
return sol;
}
RCPP_MODULE(SKWD) {
using namespace Rcpp;
function("compareAll", &compareAll,
List::create(_["Coordinates"], _["Weights"], _["L"] = 3,
_["recode"] = true, _["method"] = "approx",
_["algorithm"] = "colgen", _["model"] = "mincostflow",
_["verbosity"] = "silent", _["timelimit"] = 14400,
_["opt_tolerance"] = 1e-06, _["unbalanced"] = false,
_["unbal_cost"] = 1e+09, _["convex"] = true),
"compare all histograms using the given search options");
}

包含的文件KWD_Histogram2D.h基本上是空的。R集线器输出的错误如下:

"rcpp_module.cpp", line 49: Error: The name function is ambiguous, void Rcpp::function<RESULT_TYPE>(const char*, RESULT_TYPE(*)(), const char*) and std::function<_Signature>.
1 Error(s) detected.

更新日期:2021年5月2日:重新运行重写文件RcppExports.cppRcppExports.R的命令Rcpp::compileAttributes()后,以前的错误消失。然而,即使是Student类的基本Rcpp教程示例也无法在OracleDeveloperStudio12.6的Solaris上运行

Error: package or namespace load failed for ‘RcppStudent’ in .doLoadActions(where, attach): error in load action .__A__.1 for package RcppStudent: loadModule(module = "RcppStudentEx", what = TRUE, env = ns, loadNow = TRUE): Unable to load module "RcppStudentEx": negative length vectors are not allowed Error: loading failed Execution halted

我刚刚在rcpp模块学生上报告了这个问题。

更新于2021年5月3日:我的C++代码使用通过OpenCSW安装的gcc-5.5在Solaris 11(通过VirtualoBox(下正确编译和运行。因此,这个错误位于我编写的Rcpp包装器和在Solaris下运行的R系统之间。

更新日期:2021年5月7日:我在下面回答了自己的问题。

重现CRAN自动构建系统上发生的问题的唯一方法是使用上提供的映像在VirtualBox中本地安装Solaris 10https://files.r-hub.io/solaris/以及按照solarischeck GitHub存储库中描述的说明更新R的版本。

最后,错误出现在我的代码中,因为浮点数之间的危险的逻辑表达式导致了无限递归调用,因此C堆栈溢出。

Solaris提出这个问题纯属偶然。

在Github的代码中335-340 行

.method("num_arcs", &KWD::Solver::num_arcs,
"get the number of arcs in the Network model")
.method("num_nodes", &KWD::Solver::num_nodes,
"get the number of arcs in the Network model")

不应该是第二个节点吗?

.method("num_nodes", &KWD::Solver::num_nodes,
"get the number of nodes in the Network model")

最新更新