我正在使用RInside將R集成到Qt應用程序中。目前,我正在嘗試運行Rinside軟件包中的Qt示例。我能夠構建該示例,但創建嵌入式R實例時執行會停滯。創建嵌入式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:紅帽企業Linux客戶端版本5.8(Tikanga)
R:3.1.1
Rcpp庫:0.11.4
邊緣庫: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’
幾周前我上次重訪時,仍然在Ubuntu上工作。你需要提供更多的細節,我也會建議嘗試一些更簡單的例子。 –
@DirkEddelbuettel嗨德克,我現在試圖在標準文件夾內運行rinside_sample0示例,但仍面臨同樣的問題。我已經用更多的細節更新了這個問題。請看一看。 – Ayush
您的構建日誌只是部分。我懷疑R可能不會構建爲共享庫,從而無法在該平臺上進行嵌入。 –