[Rcpp-devel] LinkingTo: again

Romain François francoisromain at free.fr
Mon Dec 14 09:11:32 CET 2009


On 12/13/2009 10:54 PM, Dirk Eddelbuettel wrote:
>
> On 13 December 2009 at 21:59, Romain François wrote:
> | On 12/13/2009 09:57 PM, Romain François wrote:
> |>  On 12/13/2009 09:39 PM, Dirk Eddelbuettel wrote:
> |>>
> |>>  On 13 December 2009 at 21:06, Romain François wrote:
> |>>  | No, you don't need to do any of that. you can if you want (I think you
> |>>  | define what Matrix uses), but you don't have to. As far as I can see
> |>>  it,
> |>>  | adding "LinkingTo: foo" to the DESCRIPTION file just adds
> |>>  | -Isomewhere/foo/include so that you can then do #include<somefile.h>
> |>>  | where somefile.h is in the somewhere/foo/include directory.
> |>>  |
> |>>  | This is it, no voodoo needed.
> |>>
> |>>  Then that passes the _compile_ stage as you find headers and the blows up
> |>>  when the _linking_ stage finds no object code.
> |>>
> |>>  Some voodoo needed, after all. ;-)
> |>>
> |>>  [ That is, unless you're Whit Armstrong and you do everything in C++
> |>>  templates without object code. Rcpp will need -lRcpp to be found
> |>>  somewhere. ]
> |>>
> |>>  I looked at what Martin had suggested and it is all C code. So no example
> |>>  there either.
> |>>
> |>>  Dirk
> |>
> |>  This is what I've just realized when trying to make an example
> |>  (attached).
> |
> | BTW, this example assumes that the lib directory was copied over to include.
> |
> |>  now I understand your point.
> |>
> |>  Then I think this is a feature request for R-devel. Having LinkingTo C++
> |>  compatible if we follow the convention (yours) of :
> |>  - having a lib directory at the root of the installed package
> |>  - containing headers and and a shared object
> |>
> |>  then LinkingTo would add the -L, -l where appropriate.
>
> Not sure if / how that will happen.

I'm studying your Makevars and will probably submit a patch to R-devel 
at some point.

> In the meantime, here is your example
> using 'cfunction' carried over from inline:
>
> #!/usr/bin/r
>
> suppressMessages(library(Rcpp))
>
> foo<- '
> 	RcppStringVector v(x);
> 	Rprintf( "size = %d\\n", v.size() ) ;
> 	return R_NilValue ;
>          '
> funx<- cfunction(signature(x="character"), foo, Rcpp=TRUE, verbose=FALSE)
>
> funx(x=c("Bling", "Blang"))

Nice.

> edd at ron:~/svn/rcpp/pkg/inst/examples/RcppInline$ ./RcppSimple.r
> size = 2
> edd at ron:~/svn/rcpp/pkg/inst/examples/RcppInline$
>
>
> I made two changes: We need to protect the \n with a second backslash, and
> something is wrong with size() for RcppStringVectorView. For RcppStringVector
> it work.   Try that last fix with your linking to example.
>
> Dirk
>


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight



More information about the Rcpp-devel mailing list