[R] Compiling only some C files

Lafaye de Micheaux Pierre Pierre.Lafaye-de-Micheaux at upmf-grenoble.fr
Mon Aug 11 23:29:46 CEST 2008


Dear Duncan,

Thanks for these precisions.

In fact, i am planning to make an R package which will help users to 
conduct simulation studies for hypothesis tests.
The results will consist in a LaTeX table containing the power of 
different test statistics for different n values and alternative 
distributions to H0.

This kind of work necessitate heavy computations so it is better done in 
C or Fortran.
The (advanced) user could add to the source tree of the package its own 
test statistics (each statistic in one separate statj.cpp file) and its 
own alternative distributions under H1 (each law in one separate lawj.cpp).
Then an R wrapper will call all of this.
The package is already pretty usable for me, but the (advanced) users 
will need to compile it each time they add some new distribution and/or 
test statistic.
This is not that difficult under Linux but more difficult under other 
OSes that lack standard compiler tools.

If you have some ideas to improve the way i planned to do it, please let 
me know.
I could send you what i have already done.

Best,

Pierre


Duncan Murdoch a écrit :
> Barry Rowlingson wrote:
>> 2008/8/11 Lafaye de Micheaux Pierre
>> <Pierre.Lafaye-de-Micheaux at upmf-grenoble.fr>:
>>> Thank you Barry,
>>>
>>> In fact, these are only C files (not C++) and i use the extern "C"
>>> directive.
>>>
>>> I would prefer not to rename the files because many of these files 
>>> serve
>>> also in other projects where they should have the .cpp extension
>>> I would also not like to merge all the *.cpp files in one unique file
>>> because many users have to provide their own C file.
>>>
>>> So i would really like to use some kind of configure or Make script, 
>>> that
>>> should be put in the source directory tree of the R package.
>>
>> If the only function of these files within the R package in question
>> is to be included into the other C++ files, then perhaps you could put
>> them in another directory and include them from there:
>>
>> #include "../extrasrc/foo.cpp"
>>
>> I'm not sure if the forward slash will work in non-Unix OSs, but it 
>> might...
> Yes, it's fine on all the R platforms.
>
> One reason to include a .cpp file is when it's code written by someone 
> else. For example, the rgl package makes use of the ftgl library, and 
> includes it in source form, with a bunch of #include's from a 
> subdirectory to pick out the needed parts. This way no changes to ftgl 
> need to be made to suit rgl.
>
> Duncan Murdoch
>> There may be some make-magic to tell make to exclude some files from
>> its implicit build rules, but I don't know what it is.
>>
>> Barry
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
Pierre Lafaye de Micheaux 

Bureau 210, bâtiment BSHM
1251 avenue centrale BP 47
38040 GRENOBLE Cedex 09
FRANCE

Tél.: 04.76.82.58.73 / Fax: 04.76.82.56.65
Pierre.Lafaye-de-Micheaux at upmf-grenoble.fr
http://www.biostatisticien.eu



More information about the R-help mailing list