Using rinside with qt in windows

I am starting to use rinside and rcpp in C ++. I just want to start from scratch, so my QT project has nothing but instantiating RInside, and I have a problem that I cannot solve. There is 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 

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 other files, there is nothing, because it is only an empty form. When I build this, I got a lot of errors, such as:

 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.

+3
source share
3 answers

You should use the Qt version built with the same toolchain as for R, i.e. the MinGW compiler assembly.

I did this once a year as a proof of concept, starting with Qt sources.

In addition, I highly recommend starting with the qtdensity.pro file that comes with examples of my RInside package.

+3
source

You must tell the linker the link to RInside before linking to Rcpp. See this rcpp-devel post .

For qtdensity to work under windows, you need to change line 46 of the qtdensity.pro file:

 QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS 

and switch the order of $$ RCPPLIBS and $$ RINSIDELIBS:

 QMAKE_LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RINSIDELIBS $$RCPPLIBS 

You must also replace single quotes with double quotes in the qtdensity.pro file, as already mentioned. These changes will be in the next version of RInside (currently 0.2.9).

In addition, you must use the same compiler to build Rcpp and RInside and to compile your Qt application.

+3
source

Just to share your “impressions” with Rcpp and Rinside so far on Windows 7 is 64 bit and Windows XP SP3 is 32 bit. I installed the latest version of R (2.15.1) and installed Rcpp and RInside from the source.

install.packages ("path / Rcpp_x.xxtar.gz", Repos = NULL, then type = "source", INSTALL_opts = "- no-multiarchitecture")

  • In win7, I could not install without the -no-multiarch option.
  • I could compile all the standard RInside examples on both systems (always with -arch32 in Makefile.win)
  • I can run the entire executable in Win7. In WinXP, I have the error "cannot load the base package"
  • for Qt qtdensity example, I no longer have "__gxx_personality_sj0" and co. error (which improved slightly). Instead, I have the following errors:

C: /R/R-2.15.1/library/RInside/lib/i386/libRInside.a (RInside.o) :. RInside.cpp :( text + 0xbd1): undefined link 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 link 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). RInside.cpp :( text + 0xd2c): undefined link to `Rcpp :: DottedPair :: operator '

which, in my opinion, is only associated with libraries that are not included properly. - Another thing I found: a script working with headers and libraries for rcpp and rinside in qtdensity.pro only works when I changed simple quotes to double quotes: instead:

$$ system ($$ R_HOME / bin / Rscript -e \ 'Rcpp: CxxFlags () \')

I changed to:

$$ system ($$ R_HOME / bin / Rscript -e \ "Rcpp: CxxFlags () \")

Keep playing with him and let him know what will happen next :) Andry

+1
source

All Articles