我正在研究提交给 CRAN 的 R 库,它可以在除 Solaris 之外的所有平台上编译。感谢R-hub builder网站,我能够在该系统上遇到两种不同类型的错误(否则我无法访问任何 Solaris 机器)。
但是,我不知道我得到的错误。此外,两个编译器的行为完全不同:
使用选项:“Oracle Solaris 10, x86, 32 bit, R-release”,我的代码编译但它在运行时崩溃并出现“segfault”。
使用选项:“Oracle Solaris 10, x86, 32 bit, R-release, Oracle Developer Studio 12.6”,代码甚至无法编译,出现一个奇怪的错误:
“rcpp_module.cpp”,第 340 行:错误:函数名称不明确,void Rcpp::function<RESULT_TYPE>(const char*, RESULT_TYPE( )(), const char ) 和 std::function<_Signature>。
由于包编译(零警告)并在 Windows、Ubuntu、CentOs、Mac OS X 上执行,但我不知道我应该寻找什么可能的错误。
有没有其他人有同样的问题?你有什么提示吗?
感谢您的支持。
2021 年 4 月 30 日更新:我已经制定了一个最小示例来重现系统Oracle Solaris 10, x86, 32 bit, R-release, Oracle Developer Studio 12.6 的R-hub builder 上的错误。结果可在此处获得。
在 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-hub输出的错误如下:
"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 日更新:重新运行Rcpp::compileAttributes()
重写文件RcppExports.cpp
和RcppExports.R
. 但是,即使是带有Student类的基本 Rcpp 教程示例也不能在带有Oracle Developer Studio 12.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-modules-student报告了这个问题。
2021 年 5 月 3 日更新:我的 C++ 代码使用通过OpenCSW安装的 gcc-5.5 在 Solaris 11(通过 VirtualoBox)下编译并正确运行。因此,该错误位于我编写的 Rcpp 包装器和在 Solaris 下运行的 R 系统之间的某处。
2021 年 5 月 7 日更新:我已经在下面回答了我自己的问题。
重现 CRAN 自动构建系统上发生的问题的唯一方法是使用https://files.r-hub.io/solaris/ 上提供的映像在 VirtualBox 中本地安装 Solaris 10并更新 R 版本按照solarischeck GitHub 存储库中描述的说明进行操作。
最后,错误出在我的代码中,因为浮点数之间的危险逻辑表达式导致无限递归调用,因此 C 堆栈溢出。
Solaris 纯属偶然地提出了这个问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句