Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

From: Cule, Erika <erika.cule05_at_imperial.ac.uk>
Date: Fri, 17 Aug 2012 12:09:07 +0000

Thank you, that is very helpful.

On 17 Aug 2012, at 12:58, Prof Brian Ripley wrote:

> What you have not told us is your platform (but it was Mac OS X the other day). The answers are different if you are doing source installs or binary installs and if the latter, by platform.

Apologies for omitting to tell you the platform. I didn't know that it makes a difference, and was thinking about how to make the code portable for submission to CRAN.

>
> If you are doing source installs on the machine to be used, configure should adjust the install accordingly.

Dirk just told me how to do that in another message.

> 
> If you transfer a binary install done without GSL to another machine with GSL, the installed package will have the GSL functions disabled.
> 
> If you transfer a binary install done with GSL to a machine without, it depends.  As both Windows and OS X binary builds use a static libgsl, they will be fine and the package will have working GSL-based functions.  In other cases with dynamic linking the package may fail to load or attempts to use the GSL-based functions may crash the R session.
> 

That is useful to know because I was wondering how I was going to make my code portable for Windows users. As I understand, when R binaries are built for windows GSL is on the computer that builds them so Windows binaries should work. (Dirk just confirmed this.)

Many thanks to Prof Ripley, Dirk Eddelbuettel and Uwe Ligges for helping me with this.

Erika

> 
> 
> On 17/08/2012 10:11, Cule, Erika wrote:

>> I have written an R package which contains C source code (in the directory pkg/src).
>>
>> Only a subset of the functions in the pkg/R directory contain a .C() call to the functions in the pkg/src directory. The rest of the package will still work and be useful without the functions containing a .C() call.
>>
>> To compile the code in pkg/src requires the GSL library. This is detailed in the SystemRequirements line of the DESCRIPTION file and the Makevars file directs the compiler to LIB_GSL.
>>
>> At what stage will installation fail for the end user if they don't have GSL installed?
>>
>> I have used Autoconf and configure, following the example in 1.2 of "Writing R Extensions" and the configure.ac file in the R package gsl, to detect whether the GSL library is installed on the computer and disable the R functions if the GSL library is not found (by using a TRUE/FALSE pattern substitution, as in the example in "Writing R Extensions"). If GSL is not available, will the package now install on another users machine with these functions disabled? Or upon installation will the installer try to install the code in pkg/src and fail because the libraries are not available?
>>
>> Is there a practical way to test this? Both of the computers I have access to have GSL available, and installation works whether I set HAVE_GSL=TRUE or HAVE_GSL=FALSE (although in the latter case the corresponding R functions are disabled).
>>
>> I hope that this is clear, and am happy to post my code if it would be useful.
>>
>> Many thanks in advance.
>>
>> Erika
>>
>> ---
>>
>> Erika Cule
>> PhD student in Statistical Genetics
>> Imperial College London
>> Department of Epidemiology and Public Health
>> erika.cule05_at_imperial.ac.uk
>> http://occamstypewriter.org/erikacule/
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> 
> 
> -- 
> Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 17 Aug 2012 - 12:12:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 17 Aug 2012 - 20:40:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive