[Rd] Customized Makefiles (C++ and R)

Selwyn-Lloyd McPherson smcphers at stanford.edu
Mon Aug 7 22:12:03 CEST 2006


If I do R CMD CHECK, R uses the makefile that came with the source  
files to create the .o files but does not create the .so file (I  
still get the "cp: *.so: No such file or directory" error). I tried  
playing around with that makefile but to no avail. I can use R CMD  
SHLIB to create the .so file from the .o files afterwards, and if I  
do RCMD CHECK again it gets past the "checking whether package  
'chpoly' can be installed ..." step but gets hung up with a set of  
new errors:

======

Error: .First.lib failed for 'chpoly'
Call sequence:
2: stop(gettextf(".First.lib failed for '%s'", libraryPkgName(package)),
        domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
See section 'Generic functions and methods' of the 'Writing R  
Extensions'
manual.
* checking replacement functions ... WARNING
Error: .First.lib failed for 'chpoly'
Call sequence:
2: stop(gettextf(".First.lib failed for '%s'", libraryPkgName(package)),
        domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
In R, the argument of a replacement function which corresponds to the  
right
hand side must be named 'value'.
* checking foreign function calls ... WARNING
Error: .First.lib failed for 'chpoly'
Call sequence:
2: stop(gettextf(".First.lib failed for '%s'", libraryPkgName(package)),
        domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
See section 'System and foreign language interfaces' of the 'Writing R
Extensions' manual.

=====

.First.lib is defined as:

.First.lib <- function(libname, pkgname) { library.dynam 
("chpoly",pkgname,libname) }

which I think is correct, but maybe not?

I tried creating a test package that uses C++ to take in some  
arguments, do some simple math, and spit them back out again and that  
works with no problem (although there is no makefile in that test  
version. . .)

If you have any ideas, let me know. . . Thanks so much!
Selwyn-Lloyd McPherson


On Aug 6, 2006, at 9:34 PM, Dirk Eddelbuettel wrote:

>
> On 6 August 2006 at 18:50, Selwyn-Lloyd McPherson wrote:
> | Hi everyone,
> |
> | I am writing a package for R and implementing a collection of C++
> | scripts with it. Unfortunately, I did not write the C++ files, so I
> | am dependent on using the supplied makefile that came with it. This
>
> Not necessarily. You as R package author are responsible of getting  
> your
> sources into a form understood by 'R CMD ... ' and friends.
>
> | works fine for compiling the program outside of R, but in trying to
> | create the package, the .o files are created but at the end I run
> | into this error:
> |
> | cp: *.so: No such file or directory
> | ERROR: compilation failed for package 'chpoly'
> |
> |
> | I think this is because the .so file is never created, but I  
> might be
> | wrong. Is there something I have to add to the makefile to ensure
> | that everything works out okay?
>
> Quite possibly, but it is hard to say from what you posted.
>
> My general advice is to fetch a few of the 700+ CRAN packages and  
> study those
> with a similar layout -- in your case with C++.  There are numerous  
> ones that
> wrap to external C++ libraries and file collections.  You should  
> fine one
> that fits.
>
> Hope this helps, Dirk
>
> -- 
> Hell, there are no rules here - we're trying to accomplish something.
>                                                   -- Thomas A. Edison
>



More information about the R-devel mailing list