问题描述
我开始在c ++中使用rinside和rcpp。我只是想从零开始,所以我的QT项目只有创建一个RInside实例,我有一个问题,我不能解决。我在项目中只有一个对话框。
I am beginning using rinside and rcpp within c++. 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. I have only one dialog form in the project.
我的项目文件:
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
主文件:
#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'
我使用R-2.15.1,RInside 0.2.7,Rcpp 0.9.10,QT 4.8.0,MinGW 4.6。 1。
I am using R-2.15.1, RInside 0.2.7, Rcpp 0.9.10, QT 4.8.0, MinGW 4.6.1.
推荐答案
在链接到Rcpp之前,你必须告诉链接器链接RInside。请参阅此rcpp-devel帖子。
You have to tell the linker to link against RInside before linking against Rcpp. See this rcpp-devel post.
对于qtdensity在windows下工作,您需要修改qtdensity.pro文件的第46行:
For qtdensity to work under windows, you need to modify line 46 of the qtdensity.pro file:
QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS
并切换$$ RCPPLIBS和$$ RINSIDELIBS的顺序:
and switch the order of $$RCPPLIBS and $$RINSIDELIBS:
QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RINSIDELIBS $$RCPPLIBS
您还必须将双引号在qtdensity.pro文件中,如上所述。这些修改将在下一版本的RInside(目前为0.2.9)。
You also have to replace single quotes with double quotes in the qtdensity.pro file, as mentioned. These modifications will be in the next version of RInside (currently 0.2.9).
此外,您必须使用相同的编译器来构建Rcpp& RInside并编译您的Qt应用程序。
In addition, you must have used the same compiler to build Rcpp & RInside and to compile your Qt application.
这篇关于在窗户中使用qt清洗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!