[英]using rinside with qt in windows
I am beginning using rinside and rcpp within c++. 我开始在c ++中使用rinside和rcpp。 I just want to start from zero so my QT project has nothing but the creation of a RInside instance and I have a problem I cannot solve.
我只想从零开始,所以我的QT项目只有创建一个RInside实例,我有一个问题,我无法解决。 I have only one dialog form in the project.
我在项目中只有一个对话框表单。
My project file: 我的项目文件:
QT += core gui
TARGET = rcpp-rinside
TEMPLATE = app
SOURCES += main.cpp\
dialog.cpp
HEADERS += dialog.h
FORMS += dialog.ui
INCLUDEPATH += C:\R\R-2.15.1\include
INCLUDEPATH += C:\R\R-2.15.1\library\Rcpp\include
INCLUDEPATH += C:\R\R-2.15.1\library\RInside\include
LIBS += -LC:\R\R-2.15.1\bin\i386 -lR
LIBS += -LC:\R\R-2.15.1\library\Rcpp\lib\i386\ -lRcpp
LIBS += -LC:\R\R-2.15.1\library\RInside\lib\i386\ -lRInside
The main file: 主文件:
#include <QtGui/QApplication>
#include "dialog.h"
int main(int argc, char *argv[])
{
RInside R(argc, argv);
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}
For the other files, there is nothing there because it's only an empty form. 对于其他文件,没有任何内容,因为它只是一个空表单。 When I build this, I got a lot of errors like the following:
当我构建它时,我遇到了很多错误,如下所示:
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x39c): undefined reference to `__gxx_personality_sj0'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x3bb): undefined reference to `_Unwind_SjLj_Register'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x419): undefined reference to `_Unwind_SjLj_Unregister'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x471): undefined reference to `_Unwind_SjLj_Resume'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x4cc): undefined reference to `__gxx_personality_sj0'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x4eb): undefined reference to `_Unwind_SjLj_Register'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x608): undefined reference to `_Unwind_SjLj_Unregister'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x64c): undefined reference to `_Unwind_SjLj_Unregister'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x746): undefined reference to `_Unwind_SjLj_Unregister'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x7f6): undefined reference to `_Unwind_SjLj_Resume'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x84c): undefined reference to `__gxx_personality_sj0'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x86b): undefined reference to `_Unwind_SjLj_Register'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x8c6): undefined reference to `_Unwind_SjLj_Unregister'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x9c5): undefined reference to `_Unwind_SjLj_Resume'
C:\R\R-2.15.1\library\RInside\lib\i386\/libRInside.a(RInside.o):RInside.cpp:(.text+0x9ec): undefined reference to `__gxx_personality_sj0'
I am using R-2.15.1, RInside 0.2.7, Rcpp 0.9.10, QT 4.8.0, MinGW 4.6.1. 我使用的是R-2.15.1,RInside 0.2.7,Rcpp 0.9.10,QT 4.8.0,MinGW 4.6.1。
You must use a version of Qt built with the same toolchain used for R -- ie the MinGW build of the compiler. 您必须使用与用于R的相同工具链构建的Qt版本 - 即编译器的MinGW构建。
I did that once years as a proof of concept starting from the Qt sources. 从Qt源开始,我做了一次这样的概念验证。
Besides that, I would strongly suggest to start from the qtdensity.pro
file that ships with the examples of my RInside package. 除此之外,我强烈建议从我的RInside软件包示例附带的
qtdensity.pro
文件开始 。
You have to tell the linker to link against RInside before linking against Rcpp. 在链接到Rcpp之前,您必须告诉链接器链接到RInside。 See this rcpp-devel post .
看到这个rcpp-devel帖子 。
For qtdensity to work under windows, you need to modify line 46 of the qtdensity.pro file: 要使qtdensity在Windows下工作,您需要修改qtdensity.pro文件的第46行:
QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS
and switch the order of $$RCPPLIBS and $$RINSIDELIBS: 并切换$$ RCPPLIBS和$$ RINSIDELIBS的顺序:
QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RINSIDELIBS $$RCPPLIBS
You also have to replace single quotes with double quotes in the qtdensity.pro file, as mentioned. 如上所述,您还必须在qtdensity.pro文件中用双引号替换单引号。 These modifications will be in the next version of RInside (currently 0.2.9).
这些修改将在下一版本的RInside(目前为0.2.9)中进行。
In addition, you must have used the same compiler to build Rcpp & RInside and to compile your Qt application. 此外,您必须使用相同的编译器来构建Rcpp和RInside并编译您的Qt应用程序。
Just to share my "experiences" with Rcpp and Rinside until now in Windows 7 64 bit and Windows XP SP3 32 bit. 只是为了与Rcpp和Rinside分享我的“经验”,直到现在在Windows 7 64位和Windows XP SP3 32位。 I installed the latest version of R (2.15.1) and installed Rcpp and RInside from source.
我安装了最新版本的R(2.15.1)并从源代码安装了Rcpp和RInside。
install.packages("path/Rcpp_x.xxtar.gz",repos=NULL,type="source",INSTALL_opts="--no-multiarch")
install.packages( “路径/ Rcpp_x.xxtar.gz”,回购= NULL,类型= “源极”,INSTALL_opts = “ - 无multiarch”)
C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xbd1): undefined reference to
Rcpp::Function::Function(std::string const&)' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xccd): undefined reference to
vtable for Rcpp::Language' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xcd9): undefined reference toRcpp::Language::update()' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xce1): undefined reference to
Rcpp::Function::~Function()' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xd2c): undefined reference to `Rcpp::DottedPair::operator'C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp :(。text + 0xbd1):对
Rcpp::Function::Function(std::string const&)' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xccd): undefined reference to
未定义引用Rcpp::Function::Function(std::string const&)' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xccd): undefined reference to
vtable的Rcpp::Function::Function(std::string const&)' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xccd): undefined reference to
for Rcpp :: Language'C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(lnsnside.o):Rsnside.cpp:(.text + 0xcd9):对Rcpp::Language::update()' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xce1): undefined reference to
未定义引用Rcpp::Language::update()' C:/R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):RInside.cpp:(.text+0xce1): undefined reference to
Rcpp :: Function ::〜Function()'C:/ R/R-2.15.1/library/RInside/lib/i386/libRInside.a(RInside.o):Rsnside.cpp :(。text + 0xd2c):对`Rcpp :: DottedPair :: operator'的未定义引用
which I believe is only related in libraries not properly included. 我认为这只与未正确包含的图书馆有关。 - Another thing I found: the script dealing with headers and libs for rcpp and rinside in qtdensity.pro work only when I changed simple quotes to double quotes : instead of :
- 我发现的另一件事:在qtdensity.pro中处理rcpp和rinside的头文件和库的脚本只有在我将简单引号更改为双引号时才起作用:而不是:
$$system($$R_HOME/bin/Rscript -e \\'Rcpp:::CxxFlags()\\')
$$ system($$ R_HOME / bin / Rscript -e \\'Rcpp ::: CxxFlags()\\')
I changed to : 我改为:
$$system($$R_HOME/bin/Rscript -e \\"Rcpp:::CxxFlags()\\")
$$ system($$ R_HOME / bin / Rscript -e \\“Rcpp ::: CxxFlags()\\”)
Still playing around with it and will let you know what's coming next :) Andry 仍然在玩它,并会让你知道接下来会发生什么:)安德里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.