开发者

Including R standalone library in a C++ source tree

开发者 https://www.devze.com 2023-02-19 03:51 出处:网络
I am working on a large open source C++ program that uses the R standalone library (libRmath, Ubuntu/Debian package r-mathlib). I want to remove this dependency: I\'d like to include the source code f

I am working on a large open source C++ program that uses the R standalone library (libRmath, Ubuntu/Debian package r-mathlib). I want to remove this dependency: I'd like to include the source code from the R standalone library in my source tree, without the entire R source code. Can this be done?

Unfortunately, the R standalone library seems tightly coupled to the rest of the R code. In the standard R source tarball, the same configure script is used for the main package and the standalone library. This configure script doesn't play well on different platforms. I am hoping that the standalone library is available as its own "standalone" source tree.

Related note: I've looked at the Rinside library, particularly via this thread. I think the method I am describing would make distribution easier, for 2 reasons: 1) users that already have R installed won't have to reconfigure their 开发者_StackOverflowinstallation (and can maintain a different version as their default installation); 2) users without R won't have to install it.

Update: fixed a typo - I'd originally referred to Rinside as Rinclude


A few points for you:

  1. Can this be done? Of course it can, just copy and paste the code for r-mathlib into your project. The licensing for that library is a very liberal LGPL. Now, is it a good idea? I don't think so. Shared libraries have upside in that you get bugfixes, easier and shorter build etc/

  2. Seems tightly coupled to the rest of the R code. No, that is factually incorrect. The whole point of r-mathlib is that you can depend just on it. I think it may still needs R headers on your system but if you define the MATHLIB_STANDALONE variable. E.g., on my Ubuntu box I just did gcc -o /tmp/rmathTest /usr/share/doc/r-mathlib/examples/test.c -lRmath -lm and the resulting binary depends on libRmath alone, not libR.

  3. Configure script doesn't play well on other platforms. That is a bold statement, don't make it anywhere near Prof Ripley. R is amazingly portable, and I fear your claim is a little lacking in empirical basics here.

What you are after can be done in different ways, and has been done in different ways. And yes there is ample documentation as well. Start with 'Writing R Extensions' and 'R Admin + Inst' and by all means come back with follow-up questions.

Lastly, in case you change your mind and you do want R inside C++, you may want to consider RInside as well. That does however create a depedencies on R, Rcpp and RInside itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消