0

我正在使用 RInside 将 R 集成到 Qt 应用程序中。目前,我正在尝试运行 RInside 包中的 Qt 示例。我能够构建示例,但在创建嵌入式 R 实例时执行卡住了。

#include <QApplication>
#include "qtdensity.h"

int main(int argc, char *argv[])
{
    qDebug() << "First";
    RInside R(argc, argv);          // Execution halts at this point
    qDebug() << "Second";
    QApplication app(argc, argv);
    QtDensity qtdensity(R);     // pass R inst. by reference
    return app.exec();
}

在创建嵌入式 R 实例时执行被卡住并且没有给出错误。

使用的工作环境

RInside 包:版本 0.2.14

Linux 版本:Red Hat Enterprise Linux Client 5.8 (Tikanga)

R:3.1.1

Rcpp 库:0.11.4

R内部库:0.2.14

Qt:4.7.4

任何帮助或建议将不胜感激。谢谢。

更新 :

现在,我正在 rinside_sample0.cpp 中尝试一个更简单的示例。

#include <RInside.h>                    // for the embedded R via RInside
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
cout << "Starting \n";
RInside R(argc, argv);              // create an embedded R instance
cout << "R instance created\n";

R["txt"] = "Hello, world!\n";   // assign a char* (string) to 'txt'

R.parseEvalQ("cat(txt)");           // eval the init string, ignoring any returns

exit(0);

}

此代码在运行时也会卡住。它卡在RInside R(argc, argv);

现在,当我将 R_HOME 设置为我的 R 目录时,执行给了我这个错误:

cannot find system Renviron
Fatal error: unable to open the base package

编译日志:

g++ -I/pkg/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/include -I/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include -I/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/include -g -O2 -Wall -I/usr/local/include   rinside_sample0.cpp  -Wl,--export-dynamic -fopenmp  -L/pkg/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/lib -lR -lrt -ldl -lm -licuuc -licui18n -Wl,-rpath,"/pkg/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5"/lib -L/pkg/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/lib -lRblas -L/pkg/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/lib -lRlapack  -L/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/lib -lRInside -Wl,-rpath,/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/lib -o rinside_sample0
In file included from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/RcppCommon.h:34,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp.h:27,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/include/RInsideCommon.h:38,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/include/RInside.h:26,
                 from rinside_sample0.cpp:10:
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:35: warning: ignoring #pragma push_macro
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:40: warning: ignoring #pragma push_macro
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:45: warning: ignoring #pragma push_macro
In file included from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/RcppCommon.h:34,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp.h:27,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/include/RInsideCommon.h:38,
                 from /pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/RInside/include/RInside.h:26,
                 from rinside_sample0.cpp:10:
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:60: warning: ignoring #pragma pop_macro
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:64: warning: ignoring #pragma pop_macro
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/r/headers.h:68: warning: ignoring #pragma pop_macro
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/Date.h: In member function ‘void Rcpp::Date::update_tm()’:
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/Date.h:108: warning: converting to ‘time_t’ from ‘double’
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/Date.h: In function ‘Rcpp::Date Rcpp::operator+(const Rcpp::Date&, int)’:
/pkg/.site/pkgs05/OSS-R-/3.1.1/x86_64-linux2.6-glibc2.5/lib64/R/library/Rcpp/include/Rcpp/Date.h:139: warning: converting to ‘time_t’ from ‘double’
4

1 回答 1

0

谢谢德克的建议。我正在使用的R installation那个是建立在RHEL6我正在研究的RHEL5。所以,我重新安装了 R 包。我在我的机器上安装R 3.1.3了兼容RInsideRcpp库。RHEL5安装修复后,示例开始运行。

使用的工作环境

RInside 包:版本 0.2.14

Linux 版本:Red Hat Enterprise Linux Client 5.8 (Tikanga)

R:3.1.3

Rcpp 库:0.12.12

R内部库:0.2.14

Qt:4.7.4

于 2017-08-14T18:11:52.013 回答