How to use Rcpp in Qt (with Mac) [Almost Solved]?
-
Thanks for your helpful reply!
Well, I have got a problem with the initial task: "sudo: apt-get: command not found" - in the Terminal.
I am using a Mac OS X Yosemite.So I have been only able to install it in R Studio... (where it runs nicely!)
But, I would like to use Rcpp in Qt creator!
Any suggestions to install and run it as it should work?
Or is there an easier way of installing it directly via Qt?
Please let me know!
-
There is nothing as "installing it via Qt". If you have installed it in R Studio then you just need to locate the R library and the header files I mentioned above. Then adjust the paths in your *.pro file.
-
Thanks! I understand.
Well in R Studio I identified the R library with ".Library"and I got:
.Library
[1] "/Library/Frameworks/R.framework/Resources/library"In combination with your suggestion I tried this:
INCLUDEPATH += /Users/xy/share/R/include
INCLUDEPATH += /Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/include
LIBS += -L/Users/xy/lib -lR
but it was not working... -
Sorry, but I can't help you with Mac OS. :-(
-
Okay! Thank you very much for your help!
-
You're welcome!
-
Hi and welcome to devnet,
Try with
-framework R
in place of -lR -
Thanks!
Well, now I have got:
INCLUDEPATH += /Users/xy/share/R/include
INCLUDEPATH += /Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/include
LIBS += -L/Users/xy/Library -framework Rbut I still get:
'Rcpp.h' file not foundalso if change to:
LIBS += -L/Users/xy/Library/Frameworks/R.framework/and when I typed in R Studio:
getw()I got:
/Users/xySorry, but I do not find the mistake. Any idea?
-
It depends on how you wrote your includes
What mistake are you thinking about ?
-
I wrote my include: #include "Rcpp.h" in mainwindow.cpp.
It is not conflicting with: #include "math.h", or?And it displays: directory not found for: LIBS += -L/Users/xy/Library/Frameworks/R.framework/ and also for: LIBS += -L/Users/xy/Library -framework R
-
To add a path for frameworks you should user
-F /Users/xy/Library/Frameworks/
The includes are generally in fwname.framework/Headers -
Hi!
Sorry, but Qt still does not find the "Rccp.h" file. I tried to include #include "Rcpp.h" in mainwindow.cpp or in mainwindow.h. Or should I include it in main.cpp?
and additionally I wrote in the .pro-file:
HEADERS += mainwindow.hFORMS += mainwindow.ui
INCLUDEPATH += /Users/xy/share/R/include
INCLUDEPATH += /Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/include
LIBS += -L/Users/xy/Library/Frameworks/R.framework/
INCLUDEPATH += -F/Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/includeand I tried: INCLUDEPATH += "/Users/.../include" using: "..." but same result.
In RStudio it gives me:
.Library
[1] "/Library/Frameworks/R.framework/Resources/library"
getwd()
[1] "/Users/xy"So I combined: "/Users/xy/Library/Frameworks/R.framework/Resources/library"
Unfortunately, always the same result 'Rcpp.h' not found.
Even they: https://stat.ethz.ch/pipermail/r-sig-mac/2011-May/008270.html found
"/Library/Frameworks/R.framework/Resources/library" should be alright!Has got anyone an idea?
I just want to use 'Rcpp.h' (which I already installed via RStudio, where it loads and runs without any problems) in Qt with a Mac. :-)
-
Has anyone an idea to get Rcpp.h http://dirk.eddelbuettel.com/code/rcpp/html/Rmath_8h.html
running in Qt with a Mac? -
Hi again!
Can you open the directory "/Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/include" with a file manager? Does it contain the file "Rcpp.h" ? -
Hi,
I tried to re-install Rcpp.h:- installing source package ‘Rcpp’ ...
** Paket ‘Rcpp’ erfolgreich entpackt und MD5 Summen überprüft
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include
...
...
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded - DONE (Rcpp)
then I used:
INCLUDEPATH += /Users/xy/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include
LIBS += -I/Library/Frameworks/R.framework/Resources/include
or
LIBS += -F/Library/Frameworks/R.framework/Resources/includeIt still does not run!
- installing source package ‘Rcpp’ ...
-
Hallo :-)
-o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o
I see that some object code files have been installed. But are you really sure that the file "Rcpp.h" exists in "/Users/xy/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" ? Maybe the Rcpp project has been split in two separate packages: One package only for software that uses Rcpp binaries and a second package for developers that includes all the header files (so called "-dev" package)?
-
Hi Wieland!
Thanks! Yes it exists!
I checked (in the Terminal): cd /Library/Frameworks/R.framework/Resources/library
and then "ls"And it is there: Rcpp
Then i changed to: cd Rcpp and "ls" gave me:
CITATION NAMESPACE THANKS examples libs
DESCRIPTION NEWS.Rd announce help prompt
INDEX R discovery html skeleton
Meta README docThis was initially downloaded from: http://cran.r-project.org/web/packages/Rcpp/index.html
And I changed:
INCLUDEPATH += /Users/xy/Library/Frameworks/R.framework/Resources/library/Rcpp/include
LIBS += -I/Users/xy/Library/ -framework R
in the .Pro-file.Any ideas?
-
Sorry for being pedantic on this (I'm only as pedantic as the compiler is ;-) ). You said:
cd /Library/Frameworks/R.framework/Resources/library
And it is there: RcppThat is a directory. Where exactly is the file Rcpp.h?
-
Hi Wieland, thanks for your hint!
Finally, I found Rcpp.h and I managed to include it with the correct path and now Rcpp.h is found!
Here the two steps, which helped me to solve it:- QMAKE_LFLAGS += -I /Library/Frameworks/R.framework/Resources/library/Rcpp/ # use qmake and then uncomment it
- INCLUDEPATH += -I /Library/Frameworks/R.framework/Resources/library/Rcpp/include
Remark: Very important was to change the path directly to /Library/... and include "-I".
This first part of the problem is solved!
But now, i get the new error message: framework not found R.
I use: LIBS += -framework R
in the .Pro-file (as suggested here: http://doc.qt.io/qt-4.8/qmake-platform-notes.html).
I also tried: LIBS += -framework -lR
it also did not work.Here is the error message:
ld: framework not found R
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [xy.app/Contents/MacOS/xy] Error 1
19:13:17: Der Prozess "/usr/bin/make" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen/Deployment des Projekts xy (Kit: Desktop Qt 5.4.1 clang 64bit)
Bei der Ausführung von Schritt "Make"I hope this second part can also be solved. Then it should work! Any suggestions?
-
Hi,
Did you add
-F/Library/Frameworks
to your pro file ? It's the equivalent to -L for libraries