Rcpp, best method for linking to

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Rcpp, best method for linking to

Andrew Garbutt
Dear all,

 

After a bit of reading I came across the Rcpp example package.  There
are a few classes that I would like to use and I am not sure how best to
include them in my own package.  Is it best to compile it as an
independent library and link to it? Or is there some way to `require` it
for my own package?  Re-write using the code as an example (unsure how
best to do this at this moment, as the Rcpp package is licensed under
the GPL v2 and I am unsure of the license that I wish to use for my own
package.)  Any thoughts or ideas would be appreciated.

 

Thanks,

Andy


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Andrew Finley
Hi Andy,
Follow the suggestions for c++ in the Writing R Extensions document.
Wrap your c++ code in extern "C"{}, include your classes in the includes
(e.g., #include "myclass.h") and put the myclass.h and myclass.cpp in
the src directory along with your other code. Then R CMD build ... and R
CMD INSTALL ...  This works for me.
-Andy


On Fri, 2006-02-24 at 13:11 -0800, Andrew Garbutt wrote:

> Dear all,
>
>  
>
> After a bit of reading I came across the Rcpp example package.  There
> are a few classes that I would like to use and I am not sure how best to
> include them in my own package.  Is it best to compile it as an
> independent library and link to it? Or is there some way to `require` it
> for my own package?  Re-write using the code as an example (unsure how
> best to do this at this moment, as the Rcpp package is licensed under
> the GPL v2 and I am unsure of the license that I wish to use for my own
> package.)  Any thoughts or ideas would be appreciated.
>
>  
>
> Thanks,
>
> Andy
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
--
Research Fellow
Department of Forest Resources
University of Minnesota
Office: 305 Green Hall
Phone: (612) 624-1714
Fax: (612) 625-5212
web: http://blue.fr.umn.edu

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Dominick Samperi

Hi Andy (and Andy),

I'm not sure why there should be any licensing issues. R itself is GPL-ed,
so I just followed this convention.

Of course, you can do it yourself with extern "C" and all that. The
purpose of Rcpp.{cpp,hpp} is to enable you to write
readable code (for a C++ programmer) while hiding the error-prone
macro gymnastics that is required to fetch R parameters when using
the .Call interface. There is also a fair amount of type checking done
in the Rcpp package that relieves you of the trouble of putting many
checks in your R code.

If you are using the older, simpler .C interface this may not be
important to you. But note that the same functionality is available
through Rcpp, with the added convenience that list item names
are not dropped like they are when you use the .C interface.

Dominick

Andrew Finley wrote:

> Hi Andy,
> Follow the suggestions for c++ in the Writing R Extensions document.
> Wrap your c++ code in extern "C"{}, include your classes in the includes
> (e.g., #include "myclass.h") and put the myclass.h and myclass.cpp in
> the src directory along with your other code. Then R CMD build ... and R
> CMD INSTALL ...  This works for me.
> -Andy
>
>
> On Fri, 2006-02-24 at 13:11 -0800, Andrew Garbutt wrote:
>  
>> Dear all,
>>
>>  
>>
>> After a bit of reading I came across the Rcpp example package.  There
>> are a few classes that I would like to use and I am not sure how best to
>> include them in my own package.  Is it best to compile it as an
>> independent library and link to it? Or is there some way to `require` it
>> for my own package?  Re-write using the code as an example (unsure how
>> best to do this at this moment, as the Rcpp package is licensed under
>> the GPL v2 and I am unsure of the license that I wish to use for my own
>> package.)  Any thoughts or ideas would be appreciated.
>>
>>  
>>
>> Thanks,
>>
>> Andy
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Andrew Garbutt
In reply to this post by Andrew Garbutt
Dominick,

Sorry, that's not quite what I was asking.  I was asking more of a "best
practice" kind of question. My own C++ codes compile fine and are
accessible to R with some great #define magic.  I was noting that the
Rcpp package has some generic classes to handle conversion of SEXP
structures to STL and back again. As I far as I can see, using them
would require that I compile the C++ code into a library and link to
that library. Or copy the code into my own code base, but doing would
restrict myself to the GPL, as it would be a derivative work?? (IANAL)
At this point I do not want to commit to any particular licensure for my
package.  

So, to sum up my "actual" question...
Is it better to create a libRcpp.a and link to that? Have a copy of the
Rcpp.cpp/.hpp files in my own code base compiling them directly?
Require that any particular R installation have the requirement that the
Rcpp package be installed prior?

Thanks for your time,
Andy

-----Original Message-----
From: Dominick Samperi [mailto:[hidden email]]
Sent: Friday, February 24, 2006 2:30 PM
To: Andrew Finley
Cc: Andrew Garbutt; [hidden email]
Subject: Re: [Rd] Rcpp, best method for linking to


Hi Andy (and Andy),

I'm not sure why there should be any licensing issues. R itself is
GPL-ed,
so I just followed this convention.

Of course, you can do it yourself with extern "C" and all that. The
purpose of Rcpp.{cpp,hpp} is to enable you to write
readable code (for a C++ programmer) while hiding the error-prone
macro gymnastics that is required to fetch R parameters when using
the .Call interface. There is also a fair amount of type checking done
in the Rcpp package that relieves you of the trouble of putting many
checks in your R code.

If you are using the older, simpler .C interface this may not be
important to you. But note that the same functionality is available
through Rcpp, with the added convenience that list item names
are not dropped like they are when you use the .C interface.

Dominick

Andrew Finley wrote:
> Hi Andy,
> Follow the suggestions for c++ in the Writing R Extensions document.
> Wrap your c++ code in extern "C"{}, include your classes in the
includes
> (e.g., #include "myclass.h") and put the myclass.h and myclass.cpp in
> the src directory along with your other code. Then R CMD build ... and
R

> CMD INSTALL ...  This works for me.
> -Andy
>
>
> On Fri, 2006-02-24 at 13:11 -0800, Andrew Garbutt wrote:
>  
>> Dear all,
>>
>>  
>>
>> After a bit of reading I came across the Rcpp example package.  There
>> are a few classes that I would like to use and I am not sure how best
to
>> include them in my own package.  Is it best to compile it as an
>> independent library and link to it? Or is there some way to `require`
it
>> for my own package?  Re-write using the code as an example (unsure
how
>> best to do this at this moment, as the Rcpp package is licensed under
>> the GPL v2 and I am unsure of the license that I wish to use for my
own

>> package.)  Any thoughts or ideas would be appreciated.
>>
>>  
>>
>> Thanks,
>>
>> Andy
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Dominick Samperi
Andy,

Any of the options you mentioned (libRcpp.a, source, etc.) sound fine
to me. If the GPL is a problem I am happy to change this to some other
open source license (I'm not entirely comfortable with GPL, and used
it because R uses it). I'm open to suggestions.

Dominick

Andrew Garbutt wrote:

> Dominick,
>
> Sorry, that's not quite what I was asking.  I was asking more of a "best
> practice" kind of question. My own C++ codes compile fine and are
> accessible to R with some great #define magic.  I was noting that the
> Rcpp package has some generic classes to handle conversion of SEXP
> structures to STL and back again. As I far as I can see, using them
> would require that I compile the C++ code into a library and link to
> that library. Or copy the code into my own code base, but doing would
> restrict myself to the GPL, as it would be a derivative work?? (IANAL)
> At this point I do not want to commit to any particular licensure for my
> package.  
>
> So, to sum up my "actual" question...
> Is it better to create a libRcpp.a and link to that? Have a copy of the
> Rcpp.cpp/.hpp files in my own code base compiling them directly?
> Require that any particular R installation have the requirement that the
> Rcpp package be installed prior?
>
> Thanks for your time,
> Andy
>
> -----Original Message-----
> From: Dominick Samperi [mailto:[hidden email]]
> Sent: Friday, February 24, 2006 2:30 PM
> To: Andrew Finley
> Cc: Andrew Garbutt; [hidden email]
> Subject: Re: [Rd] Rcpp, best method for linking to
>
>
> Hi Andy (and Andy),
>
> I'm not sure why there should be any licensing issues. R itself is
> GPL-ed,
> so I just followed this convention.
>
> Of course, you can do it yourself with extern "C" and all that. The
> purpose of Rcpp.{cpp,hpp} is to enable you to write
> readable code (for a C++ programmer) while hiding the error-prone
> macro gymnastics that is required to fetch R parameters when using
> the .Call interface. There is also a fair amount of type checking done
> in the Rcpp package that relieves you of the trouble of putting many
> checks in your R code.
>
> If you are using the older, simpler .C interface this may not be
> important to you. But note that the same functionality is available
> through Rcpp, with the added convenience that list item names
> are not dropped like they are when you use the .C interface.
>
> Dominick
>
> Andrew Finley wrote:
>  
>> Hi Andy,
>> Follow the suggestions for c++ in the Writing R Extensions document.
>> Wrap your c++ code in extern "C"{}, include your classes in the
>>    
> includes
>  
>> (e.g., #include "myclass.h") and put the myclass.h and myclass.cpp in
>> the src directory along with your other code. Then R CMD build ... and
>>    
> R
>  
>> CMD INSTALL ...  This works for me.
>> -Andy
>>
>>
>> On Fri, 2006-02-24 at 13:11 -0800, Andrew Garbutt wrote:
>>  
>>    
>>> Dear all,
>>>
>>>  
>>>
>>> After a bit of reading I came across the Rcpp example package.  There
>>> are a few classes that I would like to use and I am not sure how best
>>>      
> to
>  
>>> include them in my own package.  Is it best to compile it as an
>>> independent library and link to it? Or is there some way to `require`
>>>      
> it
>  
>>> for my own package?  Re-write using the code as an example (unsure
>>>      
> how
>  
>>> best to do this at this moment, as the Rcpp package is licensed under
>>> the GPL v2 and I am unsure of the license that I wish to use for my
>>>      
> own
>  
>>> package.)  Any thoughts or ideas would be appreciated.
>>>
>>>  
>>>
>>> Thanks,
>>>
>>> Andy
>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>    
>>>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Dirk Eddelbuettel
In reply to this post by Andrew Garbutt

Andrew,

On 24 February 2006 at 15:00, Andrew Garbutt wrote:
| Sorry, that's not quite what I was asking.  I was asking more of a "best
| practice" kind of question. My own C++ codes compile fine and are
| accessible to R with some great #define magic.  I was noting that the
| Rcpp package has some generic classes to handle conversion of SEXP
| structures to STL and back again. As I far as I can see, using them
| would require that I compile the C++ code into a library and link to
| that library. Or copy the code into my own code base, but doing would
| restrict myself to the GPL, as it would be a derivative work?? (IANAL)
| At this point I do not want to commit to any particular licensure for my
| package.  

I may be misunderstanding you but here it goes: if you are using Rcpp as a
means to get to R, you still end up linking with R itself.  It is my
understanding that this implies the GPL -- or a suitable GPL-compatible
license -- for your code.

I do not see any _additional restriction_ coming in via the addition of
Rcpp. You already use GPL'ed object files / libraries via R itself. Plus
you're presumably building with R toolchain via 'R CMD INSTALL ....'

Hth, Dirk
 
--
Hell, there are no rules here - we're trying to accomplish something.
                                                  -- Thomas A. Edison

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Brian Ripley
On Fri, 24 Feb 2006, Dirk Eddelbuettel wrote:

> On 24 February 2006 at 15:00, Andrew Garbutt wrote:
> | Sorry, that's not quite what I was asking.  I was asking more of a "best
> | practice" kind of question. My own C++ codes compile fine and are
> | accessible to R with some great #define magic.  I was noting that the
> | Rcpp package has some generic classes to handle conversion of SEXP
> | structures to STL and back again. As I far as I can see, using them
> | would require that I compile the C++ code into a library and link to
> | that library. Or copy the code into my own code base, but doing would
> | restrict myself to the GPL, as it would be a derivative work?? (IANAL)
> | At this point I do not want to commit to any particular licensure for my
> | package.
>
> I may be misunderstanding you but here it goes: if you are using Rcpp as a
> means to get to R, you still end up linking with R itself.  It is my
> understanding that this implies the GPL -- or a suitable GPL-compatible
> license -- for your code.

As you know, what constitutes 'linking' and 'using' is controversial (and
legal experts do not agree except perhaps that it would need to be tested
in court and the interpretation may differ by country).  See e.g.

http://www.gnu.org/licenses/gpl-faq.html#MereAggregation

for one (extremal) viewpoint which might appear to disqualify the
distribution of any non-GPL R package.

But there are statements in the R codebase which could be taken to be more
liberal (and in the UK would be considered to have a legal bearing).

R's COPYRIGHTS file says (in connection of declaring certain header files
to be under LGPL).

     It came to our attention that some projects are interpreting GPL to
     mean that compiling against the header files or linking against a
     Windows import library brings the compiled code under the scope of
     GPL.  This would mean it would be impossible to distribute binary
     versions of non-GPL packages with compiled code which called entry
     points in the R executable or DLL, of which there are many on CRAN.

     We encourage packages to be distributed under Open Source conditions,
     but accept that this is not possible for some contributions.  Our
     intention is that export files and import libraries be `accessors'
     under clause 5 of the LGPL, so that in most cases no (additional)
     restrictions are imposed by compiling a package using the LGPL-ed
     components of R.

> I do not see any _additional restriction_ coming in via the addition of
> Rcpp. You already use GPL'ed object files / libraries via R itself. Plus
> you're presumably building with R toolchain via 'R CMD INSTALL ....'

Building with a GPLed compiler does not impose license conditions on the
executable, and similarly with the R toolchain on built packages, as far
as I am aware.

We do not currently have a mechanism for one R package to make use of the
compiled code of another.  When we do, the licence condition on the
exporting package becomes relevant.  That is already relevant for
rproxy.dll, where the author chose to use LGPL.  So I think there are
grounds for suggesting the Rcpp might be more usable under LGPL in some
circumstances.

[All I am trying to do here is to point out that there are multiple
viewpoints.]

--
Brian D. Ripley,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Rcpp -> RcppTemplate package with L-GPL

Dominick Samperi
The R package previously named Rcpp has been renamed to
RcppTemplate (version 1.4), and it is on its way to CRAN.

This is clearer because now RcppTemplate is an R package,
RcppExample is a sample R function, and Rcpp is a C++
class library.

The new package contains the Rcpp class library released
under L-GPL instead of the more restrictive GPL, and it has
been reorganized so that it can be used like a template for
creating R packages that use C++ libraries.

In particular, the Rcpp source files have been moved from src to
inst/lib, and the static library libRcpp.a is built as part of the package
install process. It is linked against when building the package
shared library and then deleted.

See the latest RcppAPI.pdf file for more information. To view it
use vignette("RcppAPI"), or simply fetch the PDF file from
RHOME/lib/RcppTemplate/doc/RcppAPI.pdf.

Be sure to remove the old package named Rcpp if present, because
otherwise there will be two vignettes named RcppAPI, and this
confuses vignette() (chokes under Windows).

Dominick

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp, best method for linking to

Dirk Eddelbuettel
In reply to this post by Brian Ripley

Brian,

On 25 February 2006 at 10:07, Prof Brian Ripley wrote:
| > I may be misunderstanding you but here it goes: if you are using Rcpp as a
| > means to get to R, you still end up linking with R itself.  It is my
| > understanding that this implies the GPL -- or a suitable GPL-compatible
| > license -- for your code.
|
| As you know, what constitutes 'linking' and 'using' is controversial (and
| legal experts do not agree except perhaps that it would need to be tested
| in court and the interpretation may differ by country).  See e.g.
[...]
| [All I am trying to do here is to point out that there are multiple
| viewpoints.]

I appreciate the follow-up and clarification because it is indeed difficult
and not fully mapped territory.  But now that Dominick has released the RCpp
/ RCppTemplate code under LGPL, things should be easier for Andrew.

It will be interesting to see what happens with GPLv3. As I understand, the
murkiness with respect to linking, and things like webservice interface is
said to be one of several drivers behind the license update.  

Dirk

--
Hell, there are no rules here - we're trying to accomplish something.
                                                  -- Thomas A. Edison

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp -> RcppTemplate package with L-GPL

Andrew Garbutt
In reply to this post by Dominick Samperi
Thank you all for your input and ideas.  It seems this discussion has
clarified the purpose of the Rcpp/RcppTemplate package and further
demonstrated both creating and linking with an external library as well
as utilizing C++ for creating R packages.  Moving the Rcpp code base to
a separate library encourages using its variable parsing in other
packages.  Thank you again.

-Andy


-----Original Message-----
From: Dominick Samperi [mailto:[hidden email]]
Sent: Saturday, February 25, 2006 11:51 AM
To: Prof Brian Ripley; Andrew Finley
Cc: Dirk Eddelbuettel; Andrew Garbutt; [hidden email]
Subject: Rcpp -> RcppTemplate package with L-GPL

The R package previously named Rcpp has been renamed to
RcppTemplate (version 1.4), and it is on its way to CRAN.

This is clearer because now RcppTemplate is an R package,
RcppExample is a sample R function, and Rcpp is a C++
class library.

The new package contains the Rcpp class library released
under L-GPL instead of the more restrictive GPL, and it has
been reorganized so that it can be used like a template for
creating R packages that use C++ libraries.

In particular, the Rcpp source files have been moved from src to
inst/lib, and the static library libRcpp.a is built as part of the
package
install process. It is linked against when building the package
shared library and then deleted.

See the latest RcppAPI.pdf file for more information. To view it
use vignette("RcppAPI"), or simply fetch the PDF file from
RHOME/lib/RcppTemplate/doc/RcppAPI.pdf.

Be sure to remove the old package named Rcpp if present, because
otherwise there will be two vignettes named RcppAPI, and this
confuses vignette() (chokes under Windows).

Dominick

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel