[Rcpp-devel] Rcpp package linking to C++ library that depends on Qt5 core

Dirk Eddelbuettel edd at debian.org
Mon Mar 27 19:39:01 CEST 2017


On 27 March 2017 at 19:18, info at mycontent.gr wrote:
| Dear members of the Rcpp-devel list,
| 
| I would like to ask for your help with the following problem. I am 
| trying to use Rcpp to expose the functionality of a C++ library to R. 
| The C++ library is open source, but it depends on Qt (version 5, 
| preferably 5.8). It makes good use of Qt Core functionality, and 
| therefore needs to be linked against QtCore, QtXML and the Qt database 
| plugins. The GUI functionality of Qt is not used at all (the library is 
| part of a bigger project, all built on Qt).

Michael Lawrence once worked on a follow-up to RGtk2 using Qt, I don't quite
remember what became of this. 

Other than that, not too sure who has done that.
 
| Although I've searched for packages in a similar situation, I can't find 
| how to do this in a proper, cross-platform way. I could tweak with the 
| Makevars files to make it run on my machine, but this will not allow me 
| to distribute a package.
| 
| I am wondering if anyone has experience with this type of dependency for 
| an R package. Could you please point me in the right direction? (e.g. 
| another open source package for R that includes C++ code that depends on 
| Qt 5 core libraries). Do you think it would be possible to find a 
| solution that would allow me to host the package on CRAN?

It's complicated. In essence, you have two choices:

 a) embed the library and build it locally

 b) have an external dependency

Most of us now think b) is clearly better, but people still do a). Given the
size and scope of Qt I think it would utter madness to go that way.

So I'd start simple.  Add some compile-time configuration to your package in
a script 'configure'.  You can use autoconf, or you can just use a shell
script -- I do that in a few packages, Jeroen does it all the time as he
dislikes autoconf (wrongly, in my book, but that is another story).

For a recent package with external depends (and hence somewhat limited
portability) look here:    https://github.com/rcppmlpack/rcppmlpack2

| Apologies if this is not the correct mailing list for this question. 
| Thank you for your time!

Absolutely the right venue, but for general packaging questions also consider
r-package-devel which has turned into a very helpful venue.

Hth,  Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list