Abe
Abe

Reputation: 13544

Is there any way to access C source code in an R package binary?

I would like to share my R package but keep the source code until after an article is published. If I compile a package using R CMD INSTALL --build, is there any way for an end user to read the C source code?

According to p 44 of R News 2006-4,

In order to access the sources of compiled code (i.e., C, C++, or Fortran), it is not sufficient to have the binary version of R or a contributed package installed.

I would be satisfied with this knowledge (indeed, I would prefer to release the source), but I need to assuage the fears of my collaborators.

My primary question is to confirm: if I distribute a binary created by R CMD INSTALL --build, will the C source be inaccessible?


Update: it is not very clear to me why this question has received so many down votes (4 at this point). A downvote indicates "This question has not shown any research effort; it is unclear or not useful". I am only asking about native R functionality, not trying to promote any nefarious intent.

Upvotes: 4

Views: 809

Answers (2)

Spacedman
Spacedman

Reputation: 94317

If the .c source files aren't in the distributed archive file (a .tar.gz for Linux, maybe a .zip for Windows) then no, you can't get the source. I just did a quick test with a skeletal package and a single foo.c file and its not there for me, just a compiled foo.so file.

Unless you've used Rcpp and put the C code into inline R functions, of course.

Upvotes: 2

user2597359
user2597359

Reputation: 51

If you have only binary file output it is inaccessible for source code. Only way to get in to some idea is to disassembly. Of course all of your header files should be also compiled.

Upvotes: 1

Related Questions