Discussion:
[Rcpp-devel] Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool
Yue Li
2017-05-04 14:16:47 UTC
Permalink
Dear List,

This is probably a dumb question:

Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool?

I was thinking about something similar to the 'python setup.py install’ thing. Once the software is built, the binary executable can be added to /usr/bin/ and invoked directly on command line without the R environment.

I apologize as the question seems to be spoiled in that i could write everything in cpp in the first place ...

many thanks!
Yue
Dale Smith
2017-05-04 14:30:13 UTC
Permalink
Wrap the Rcpp headers in an #if/#endif. That way, when you our outside of R, the Rcpp code is skipped.

I used this idea in 2013-2014 to build in R using Rcpp, and the same code in Visual Studio.

Dale Smith

-----Original Message-----
Sent: May 4, 2017 10:16 AM
Subject: [Rcpp-devel] Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool
Dear List,
Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool?
I was thinking about something similar to the 'python setup.py install’ thing. Once the software is built, the binary executable can be added to /usr/bin/ and invoked directly on command line without the R environment.
I apologize as the question seems to be spoiled in that i could write everything in cpp in the first place ...
many thanks!
Yue
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel
2017-05-04 14:33:09 UTC
Permalink
On 4 May 2017 at 10:16, Yue Li wrote:
| Dear List,
|
| This is probably a dumb question:
|
| Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool?
|
| I was thinking about something similar to the 'python setup.py install’ thing. Once the software is built, the binary executable can be added to /usr/bin/ and invoked directly on command line without the R environment.

Not quite. "All you get" is python script with, say '#!/usr/bin/python'
loading the packaged modules. And *not* a binary executable.

And guess what: all that exists for R too via littler and Rscript. Maybe
start here

http://dirk.eddelbuettel.com/code/littler.html

and look at all the examples here

http://dirk.eddelbuettel.com/code/littler.examples.html

and in the repo

https://github.com/eddelbuettel/littler/tree/master/inst/examples

You then deploy packages using Rcpp just any of the other R packages.

| I apologize as the question seems to be spoiled in that i could write everything in cpp in the first place ...

Yes, it was an off-topic question.

Dirk
|
| many thanks!
| Yue
|
|
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-***@lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Yue Li
2017-05-04 14:36:50 UTC
Permalink
Got it. Thank you so much Dirk!

Yue
Post by Dirk Eddelbuettel
| Dear List,
|
|
| Is there an easy way to convert Rcpp code to pure cpp code to build a command line tool?
|
| I was thinking about something similar to the 'python setup.py install’ thing. Once the software is built, the binary executable can be added to /usr/bin/ and invoked directly on command line without the R environment.
Not quite. "All you get" is python script with, say '#!/usr/bin/python'
loading the packaged modules. And *not* a binary executable.
And guess what: all that exists for R too via littler and Rscript. Maybe
start here
http://dirk.eddelbuettel.com/code/littler.html
and look at all the examples here
http://dirk.eddelbuettel.com/code/littler.examples.html
and in the repo
https://github.com/eddelbuettel/littler/tree/master/inst/examples
You then deploy packages using Rcpp just any of the other R packages.
| I apologize as the question seems to be spoiled in that i could write everything in cpp in the first place ...
Yes, it was an off-topic question.
Dirk
|
| many thanks!
| Yue
|
|
| _______________________________________________
| Rcpp-devel mailing list
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Loading...