Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-31 Thread Romain Francois

Le 24/01/12 22:09, Dirk Eddelbuettel a écrit :


On 24 January 2012 at 15:36, Whit Armstrong wrote:
| Thanks, Dirk, as always for the quick response.
|
| It works, but I get an unusual compile error with the most recent
| RcppArmadillo (installed with install.packages this morning).
|
| require(inline)
| require(Rcpp)
| require(RcppArmadillo)
| cppbugs.plugin<- getPlugin("RcppArmadillo")
| cppbugs.plugin$env$PKG_CXXFLAGS<- "-std=c++0x"
| foo<- cxxfunction(signature(hat="numeric"), body="return
| R_NilValue;",settings=cppbugs.plugin)
|
| results in:
|
| Error in compileCode(f, code, language = language, verbose = verbose) :
|   Compilation ERROR, function(s)/method(s) not created! In file
| included from 
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6091:0,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:369,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:36,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:25,
|  from file1724747be803.cpp:3:
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:
| In function ‘void arma::RcppArmadillo::check()’:
| 
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:34:5:
| error: expected ‘;’ before ‘}’ token
| make: *** [file1724747be803.o] Error 1
| In addition: Warning message:
| running command '/usr/lib/R/bin/R CMD SHLIB file1724747be803.cpp 2>
| file1724747be803.cpp.err.txt' had status 1


Easy enough:

 inline void check(){
#if !defined(ARMA_USE_CXX11)
arma_type_check_cxx1998<  is_same_type<  eT, rcpp_type>::value == 
false>::apply();
#else
static_assert( is_same_type<  eT, rcpp_type>::value , "error: incorrect or 
unsupported type" )
#endif
 }

There is indeed a semicolon missing in the released version, but I seem to
have added that in svn commit 3438.  Should get fixed in the next release. Ah
yes, and ChangeLog says that we had this reported on Dec 31 by Teo Guo Ci

2011-12-31  Dirk Eddelbuettel

* inst/include/RcppArmadillo/Mat_meat.h: Add missing semicolon in
code ifdef'ed for C++0x mode, with thanks to Teo Guo Ci


Dirk


ooops :/


|
| Probably something I've overlooked.
|
| However, changing the 'cppbugs.plugin<- getPlugin("RcppArmadillo")'
| command to 'cppbugs.plugin<- getPlugin("Rcpp")' allows the example to
| compile.
|
| Is there a c++0x issue in the latest RcppArmadillo?  I have:
| Version:0.2.34
| Date:   $Date: 2011-12-12 16:56:37 -0600 (Mon, 12 Dec 2011) $
|
| Anyway, I'll keep tinkering...
|
| -Whit
|
|
|
|
| On Tue, Jan 24, 2012 at 3:18 PM, Dirk Eddelbuettel  wrote:
|>
|>  On 24 January 2012 at 14:46, Whit Armstrong wrote:
|>  | using cxxfunction is there an easy (not using a custom plugin) way to
|>  | add -std=c++0x to the g++ call?
|>
|>  The best way, I think, is to call a plugin and to modify it.
|>
|>  Quick example:
|>
|>
|>  R>  myplugin<- getPlugin("Rcpp")
|>  R>  myplugin$env$PKG_CXXFLAGS<- "-std=c++0x"
|>  R>  f<- cxxfunction(signature(), settings=myplugin, body='
|>  +std::vector  x = { 1.0, 2.0, 3.0 };  // fails without 
-std=c++0x
|>  +return Rcpp::wrap(x);
|>  + ')
|>  R>  f()
|>  [1] 1 2 3
|>  R>
|>
|>
|>  If you don't use the modified settings, it'll blow up as the 'curly init' is
|>  a new feature:
|>
|> filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by 
constructor, not by ‘{...}’
|> filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, 3.0e+0}’ from 
‘’ to ‘std::vector’
|>
|>  but with the switch it all flies.
|>
|>  I think I'll add that to the Rcpp-FAQ now.
|>
|>  Note though that here I simply assigned PKG_CXXFLAGS which had been empty as
|>  the Rcpp plugin does not set it. Other plugins may, so you one may have
|>  append rather than overwrite.
|>
|>  Dirk
|>
|>  --
|>  "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
|>  dark to read." -- Groucho Marx




--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://addictedtor.free.fr/graphiques
blog:http://romainfrancois.blog.free.fr
|- http://bit.ly/xbKv0R : Crawling facebook with R
|- http://bit.ly/v3WB8S : ... And now for solution 17, still using Rcpp
`- http://bit.ly/uaQDGr : int64: 64 bit integer vectors for R
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-31 Thread Romain Francois

Le 24/01/12 22:27, Whit Armstrong a écrit :

yes, unless I add

#include

Then it blows up.


Don't do that. When using RcppArmadillo, you do:

#include 

Some magic happens when you do that. Not sure it solves your issue though.

Romain


The problem is in my real function I include a header, which includes armadillo.

So, unless I go deleting all the refs to #include, I think
it will continue to blow up...  (with the current released version).

Anyway, I'll just wait for the next release.

Thanks,
Whit


On Tue, Jan 24, 2012 at 4:23 PM, Dirk Eddelbuettel  wrote:


Slow down. You are rushing things a little:

a) we _do_ want the Arma plugin, it does more than just one setting

b) once we have it, Arma works fine:

require(inline)
cppbugs.plugin<- getPlugin("RcppArmadillo")  ## Arma!!
cppbugs.plugin$env$PKG_CXXFLAGS<- "-std=c++0x"
foo.bar<- cxxfunction(signature(hat="numeric"), body='
   arma::colvec v(2);
   return Rcpp::wrap(v);
', settings=cppbugs.plugin, verbose=TRUE)


Dirk

--
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://addictedtor.free.fr/graphiques
blog:http://romainfrancois.blog.free.fr
|- http://bit.ly/xbKv0R : Crawling facebook with R
|- http://bit.ly/v3WB8S : ... And now for solution 17, still using Rcpp
`- http://bit.ly/uaQDGr : int64: 64 bit integer vectors for R
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-25 Thread Dirk Eddelbuettel

On 25 January 2012 at 09:52, Whit Armstrong wrote:
| Ok, all set w/ lastest svn (Revision: 3445)
| 
| One question on the build.  I can successfully install if I use --no-vignettes
| 
| However, with default args:
| 
| R CMD build Rcpp
| ...
| ...
| ...
| /usr/lib/R/bin/Rscript --vanilla -e "require(highlight); driver <-
| HighlightWeaveLatex(boxes = TRUE, bg = ‘white’ ); Sweave(
| ‘Rcpp-modules.Rnw’, driver = driver ); "
| Loading required package: highlight
| Loading required package: tools
| Loading required package: codetools
| Loading required package: parser
| Loading required package: Rcpp
| Writing to file Rcpp-modules.tex
| Processing code chunks with options ...
|  1 : keep.source term verbatim
| Loading required package: inline
|  2 : keep.source term verbatim
| terminate called after throwing an instance of ‘Rcpp::not_compatible’
|   what():  expecting a single value
| Aborted
| make: *** [Rcpp-modules.pdf] Error 134
| Error in tools::buildVignettes(dir = ".") : running ‘make’ failed
| Execution halted
| warmstrong@krypton:~/dvl/R.packages/external$
| 
| Is this a missing dependency on my workstation?

Try rev3446. What I added yesterday had a latex issue. Should be fine now.

Thanks, Dirk

| 
| seems to be here too:
| 
http://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-gcc-fedora/Rcpp-00check.html
| 
| -Whit
| 
| 
| On Tue, Jan 24, 2012 at 4:58 PM, Whit Armstrong
|  wrote:
| > Thanks for your help.
| >
| > -Whit
| >
| >
| > On Tue, Jan 24, 2012 at 4:39 PM, Dirk Eddelbuettel  wrote:
| >>
| >> On 24 January 2012 at 16:27, Whit Armstrong wrote:
| >> | yes, unless I add
| >> |
| >> | #include 
| >> |
| >> | Then it blows up.
| >> |
| >> | The problem is in my real function I include a header, which includes 
armadillo.
| >> |
| >> | So, unless I go deleting all the refs to #include , I think
| >> | it will continue to blow up...  (with the current released version).
| >> |
| >> | Anyway, I'll just wait for the next release.
| >>
| >> I give up now. I told you three emails ago that it is either a one char 
fix,
| >> or an update to SVN. Is that really so hard?
| >>
| >> As for mucking with the headers: that requires care because of forward
| >> declarations for as and wrap and all the like but if you had it working
| >> before 
| >>
| >> Dirk
| >>
| >> --
| >> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is 
too
| >> dark to read." -- Groucho Marx

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-25 Thread Whit Armstrong
Ok, all set w/ lastest svn (Revision: 3445)

One question on the build.  I can successfully install if I use --no-vignettes

However, with default args:

R CMD build Rcpp
...
...
...
/usr/lib/R/bin/Rscript --vanilla -e "require(highlight); driver <-
HighlightWeaveLatex(boxes = TRUE, bg = ‘white’ ); Sweave(
‘Rcpp-modules.Rnw’, driver = driver ); "
Loading required package: highlight
Loading required package: tools
Loading required package: codetools
Loading required package: parser
Loading required package: Rcpp
Writing to file Rcpp-modules.tex
Processing code chunks with options ...
 1 : keep.source term verbatim
Loading required package: inline
 2 : keep.source term verbatim
terminate called after throwing an instance of ‘Rcpp::not_compatible’
  what():  expecting a single value
Aborted
make: *** [Rcpp-modules.pdf] Error 134
Error in tools::buildVignettes(dir = ".") : running ‘make’ failed
Execution halted
warmstrong@krypton:~/dvl/R.packages/external$

Is this a missing dependency on my workstation?

seems to be here too:
http://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-gcc-fedora/Rcpp-00check.html

-Whit


On Tue, Jan 24, 2012 at 4:58 PM, Whit Armstrong
 wrote:
> Thanks for your help.
>
> -Whit
>
>
> On Tue, Jan 24, 2012 at 4:39 PM, Dirk Eddelbuettel  wrote:
>>
>> On 24 January 2012 at 16:27, Whit Armstrong wrote:
>> | yes, unless I add
>> |
>> | #include 
>> |
>> | Then it blows up.
>> |
>> | The problem is in my real function I include a header, which includes 
>> armadillo.
>> |
>> | So, unless I go deleting all the refs to #include , I think
>> | it will continue to blow up...  (with the current released version).
>> |
>> | Anyway, I'll just wait for the next release.
>>
>> I give up now. I told you three emails ago that it is either a one char fix,
>> or an update to SVN. Is that really so hard?
>>
>> As for mucking with the headers: that requires care because of forward
>> declarations for as and wrap and all the like but if you had it working
>> before 
>>
>> Dirk
>>
>> --
>> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
>> dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Whit Armstrong
Thanks for your help.

-Whit


On Tue, Jan 24, 2012 at 4:39 PM, Dirk Eddelbuettel  wrote:
>
> On 24 January 2012 at 16:27, Whit Armstrong wrote:
> | yes, unless I add
> |
> | #include 
> |
> | Then it blows up.
> |
> | The problem is in my real function I include a header, which includes 
> armadillo.
> |
> | So, unless I go deleting all the refs to #include , I think
> | it will continue to blow up...  (with the current released version).
> |
> | Anyway, I'll just wait for the next release.
>
> I give up now. I told you three emails ago that it is either a one char fix,
> or an update to SVN. Is that really so hard?
>
> As for mucking with the headers: that requires care because of forward
> declarations for as and wrap and all the like but if you had it working
> before 
>
> Dirk
>
> --
> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
> dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Dirk Eddelbuettel

On 24 January 2012 at 16:27, Whit Armstrong wrote:
| yes, unless I add
| 
| #include 
| 
| Then it blows up.
| 
| The problem is in my real function I include a header, which includes 
armadillo.
| 
| So, unless I go deleting all the refs to #include , I think
| it will continue to blow up...  (with the current released version).
| 
| Anyway, I'll just wait for the next release.

I give up now. I told you three emails ago that it is either a one char fix,
or an update to SVN. Is that really so hard?

As for mucking with the headers: that requires care because of forward
declarations for as and wrap and all the like but if you had it working
before 

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Whit Armstrong
yes, unless I add

#include 

Then it blows up.

The problem is in my real function I include a header, which includes armadillo.

So, unless I go deleting all the refs to #include , I think
it will continue to blow up...  (with the current released version).

Anyway, I'll just wait for the next release.

Thanks,
Whit


On Tue, Jan 24, 2012 at 4:23 PM, Dirk Eddelbuettel  wrote:
>
> Slow down. You are rushing things a little:
>
> a) we _do_ want the Arma plugin, it does more than just one setting
>
> b) once we have it, Arma works fine:
>
> require(inline)
> cppbugs.plugin <- getPlugin("RcppArmadillo")      ## Arma!!
> cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"
> foo.bar <- cxxfunction(signature(hat="numeric"), body='
>   arma::colvec v(2);
>   return Rcpp::wrap(v);
> ', settings=cppbugs.plugin, verbose=TRUE)
>
>
> Dirk
>
> --
> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
> dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Dirk Eddelbuettel

Slow down. You are rushing things a little:

a) we _do_ want the Arma plugin, it does more than just one setting

b) once we have it, Arma works fine:

require(inline)
cppbugs.plugin <- getPlugin("RcppArmadillo")  ## Arma!!
cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"
foo.bar <- cxxfunction(signature(hat="numeric"), body='
   arma::colvec v(2);
   return Rcpp::wrap(v);
', settings=cppbugs.plugin, verbose=TRUE)


Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Dirk Eddelbuettel

On 24 January 2012 at 15:36, Whit Armstrong wrote:
| Thanks, Dirk, as always for the quick response.
| 
| It works, but I get an unusual compile error with the most recent
| RcppArmadillo (installed with install.packages this morning).
| 
| require(inline)
| require(Rcpp)
| require(RcppArmadillo)
| cppbugs.plugin <- getPlugin("RcppArmadillo")
| cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"
| foo <- cxxfunction(signature(hat="numeric"), body="return
| R_NilValue;",settings=cppbugs.plugin)
| 
| results in:
| 
| Error in compileCode(f, code, language = language, verbose = verbose) :
|   Compilation ERROR, function(s)/method(s) not created! In file
| included from 
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6091:0,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:369,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:36,
|  from
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:25,
|  from file1724747be803.cpp:3:
| /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:
| In function ‘void arma::RcppArmadillo::check()’:
| 
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:34:5:
| error: expected ‘;’ before ‘}’ token
| make: *** [file1724747be803.o] Error 1
| In addition: Warning message:
| running command '/usr/lib/R/bin/R CMD SHLIB file1724747be803.cpp 2>
| file1724747be803.cpp.err.txt' had status 1


Easy enough:

inline void check(){
#if !defined(ARMA_USE_CXX11)
arma_type_check_cxx1998< is_same_type< eT, rcpp_type >::value == false 
>::apply();
#else
static_assert( is_same_type< eT, rcpp_type >::value , "error: incorrect 
or unsupported type" )
#endif
}

There is indeed a semicolon missing in the released version, but I seem to
have added that in svn commit 3438.  Should get fixed in the next release. Ah
yes, and ChangeLog says that we had this reported on Dec 31 by Teo Guo Ci

2011-12-31  Dirk Eddelbuettel  

* inst/include/RcppArmadillo/Mat_meat.h: Add missing semicolon in
code ifdef'ed for C++0x mode, with thanks to Teo Guo Ci


Dirk


| 
| Probably something I've overlooked.
| 
| However, changing the 'cppbugs.plugin <- getPlugin("RcppArmadillo")'
| command to 'cppbugs.plugin <- getPlugin("Rcpp")' allows the example to
| compile.
| 
| Is there a c++0x issue in the latest RcppArmadillo?  I have:
| Version:0.2.34
| Date:   $Date: 2011-12-12 16:56:37 -0600 (Mon, 12 Dec 2011) $
| 
| Anyway, I'll keep tinkering...
| 
| -Whit
| 
| 
| 
| 
| On Tue, Jan 24, 2012 at 3:18 PM, Dirk Eddelbuettel  wrote:
| >
| > On 24 January 2012 at 14:46, Whit Armstrong wrote:
| > | using cxxfunction is there an easy (not using a custom plugin) way to
| > | add -std=c++0x to the g++ call?
| >
| > The best way, I think, is to call a plugin and to modify it.
| >
| > Quick example:
| >
| >
| > R> myplugin <- getPlugin("Rcpp")
| > R> myplugin$env$PKG_CXXFLAGS <- "-std=c++0x"
| > R> f <- cxxfunction(signature(), settings=myplugin, body='
| > +    std::vector x = { 1.0, 2.0, 3.0 };  // fails without -std=c++0x
| > +    return Rcpp::wrap(x);
| > + ')
| > R> f()
| > [1] 1 2 3
| > R>
| >
| >
| > If you don't use the modified settings, it'll blow up as the 'curly init' is
| > a new feature:
| >
| >   filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by 
constructor, not by ‘{...}’
| >   filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, 
3.0e+0}’ from ‘’ to ‘std::vector’
| >
| > but with the switch it all flies.
| >
| > I think I'll add that to the Rcpp-FAQ now.
| >
| > Note though that here I simply assigned PKG_CXXFLAGS which had been empty as
| > the Rcpp plugin does not set it. Other plugins may, so you one may have
| > append rather than overwrite.
| >
| > Dirk
| >
| > --
| > "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
| > dark to read." -- Groucho Marx

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Whit Armstrong
Still not sure I get it, but here is a portable example:

require(inline)
require(Rcpp)
cppbugs.plugin <- getPlugin("Rcpp")
cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"

## this works
foo <- cxxfunction(signature(hat="numeric"), body="return
R_NilValue;",settings=cppbugs.plugin)

## this blows up
foo.bar <- cxxfunction(signature(hat="numeric"), body="#include
\nreturn R_NilValue;",settings=cppbugs.plugin,verbose=TRUE)


-Whit




On Tue, Jan 24, 2012 at 3:36 PM, Whit Armstrong
 wrote:
> Thanks, Dirk, as always for the quick response.
>
> It works, but I get an unusual compile error with the most recent
> RcppArmadillo (installed with install.packages this morning).
>
> require(inline)
> require(Rcpp)
> require(RcppArmadillo)
> cppbugs.plugin <- getPlugin("RcppArmadillo")
> cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"
> foo <- cxxfunction(signature(hat="numeric"), body="return
> R_NilValue;",settings=cppbugs.plugin)
>
> results in:
>
> Error in compileCode(f, code, language = language, verbose = verbose) :
>  Compilation ERROR, function(s)/method(s) not created! In file
> included from 
> /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6091:0,
>                 from
> /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:369,
>                 from
> /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:36,
>                 from
> /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:25,
>                 from file1724747be803.cpp:3:
> /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:
> In function ‘void arma::RcppArmadillo::check()’:
> /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:34:5:
> error: expected ‘;’ before ‘}’ token
> make: *** [file1724747be803.o] Error 1
> In addition: Warning message:
> running command '/usr/lib/R/bin/R CMD SHLIB file1724747be803.cpp 2>
> file1724747be803.cpp.err.txt' had status 1
>
>
> Probably something I've overlooked.
>
> However, changing the 'cppbugs.plugin <- getPlugin("RcppArmadillo")'
> command to 'cppbugs.plugin <- getPlugin("Rcpp")' allows the example to
> compile.
>
> Is there a c++0x issue in the latest RcppArmadillo?  I have:
> Version:            0.2.34
> Date:               $Date: 2011-12-12 16:56:37 -0600 (Mon, 12 Dec 2011) $
>
> Anyway, I'll keep tinkering...
>
> -Whit
>
>
>
>
> On Tue, Jan 24, 2012 at 3:18 PM, Dirk Eddelbuettel  wrote:
>>
>> On 24 January 2012 at 14:46, Whit Armstrong wrote:
>> | using cxxfunction is there an easy (not using a custom plugin) way to
>> | add -std=c++0x to the g++ call?
>>
>> The best way, I think, is to call a plugin and to modify it.
>>
>> Quick example:
>>
>>
>> R> myplugin <- getPlugin("Rcpp")
>> R> myplugin$env$PKG_CXXFLAGS <- "-std=c++0x"
>> R> f <- cxxfunction(signature(), settings=myplugin, body='
>> +    std::vector x = { 1.0, 2.0, 3.0 };  // fails without -std=c++0x
>> +    return Rcpp::wrap(x);
>> + ')
>> R> f()
>> [1] 1 2 3
>> R>
>>
>>
>> If you don't use the modified settings, it'll blow up as the 'curly init' is
>> a new feature:
>>
>>   filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by 
>> constructor, not by ‘{...}’
>>   filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, 
>> 3.0e+0}’ from ‘’ to ‘std::vector’
>>
>> but with the switch it all flies.
>>
>> I think I'll add that to the Rcpp-FAQ now.
>>
>> Note though that here I simply assigned PKG_CXXFLAGS which had been empty as
>> the Rcpp plugin does not set it. Other plugins may, so you one may have
>> append rather than overwrite.
>>
>> Dirk
>>
>> --
>> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
>> dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Whit Armstrong
Thanks, Dirk, as always for the quick response.

It works, but I get an unusual compile error with the most recent
RcppArmadillo (installed with install.packages this morning).

require(inline)
require(Rcpp)
require(RcppArmadillo)
cppbugs.plugin <- getPlugin("RcppArmadillo")
cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x"
foo <- cxxfunction(signature(hat="numeric"), body="return
R_NilValue;",settings=cppbugs.plugin)

results in:

Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created! In file
included from 
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6091:0,
 from
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:369,
 from
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:36,
 from
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:25,
 from file1724747be803.cpp:3:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:
In function ‘void arma::RcppArmadillo::check()’:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:34:5:
error: expected ‘;’ before ‘}’ token
make: *** [file1724747be803.o] Error 1
In addition: Warning message:
running command '/usr/lib/R/bin/R CMD SHLIB file1724747be803.cpp 2>
file1724747be803.cpp.err.txt' had status 1


Probably something I've overlooked.

However, changing the 'cppbugs.plugin <- getPlugin("RcppArmadillo")'
command to 'cppbugs.plugin <- getPlugin("Rcpp")' allows the example to
compile.

Is there a c++0x issue in the latest RcppArmadillo?  I have:
Version:0.2.34
Date:   $Date: 2011-12-12 16:56:37 -0600 (Mon, 12 Dec 2011) $

Anyway, I'll keep tinkering...

-Whit




On Tue, Jan 24, 2012 at 3:18 PM, Dirk Eddelbuettel  wrote:
>
> On 24 January 2012 at 14:46, Whit Armstrong wrote:
> | using cxxfunction is there an easy (not using a custom plugin) way to
> | add -std=c++0x to the g++ call?
>
> The best way, I think, is to call a plugin and to modify it.
>
> Quick example:
>
>
> R> myplugin <- getPlugin("Rcpp")
> R> myplugin$env$PKG_CXXFLAGS <- "-std=c++0x"
> R> f <- cxxfunction(signature(), settings=myplugin, body='
> +    std::vector x = { 1.0, 2.0, 3.0 };  // fails without -std=c++0x
> +    return Rcpp::wrap(x);
> + ')
> R> f()
> [1] 1 2 3
> R>
>
>
> If you don't use the modified settings, it'll blow up as the 'curly init' is
> a new feature:
>
>   filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by 
> constructor, not by ‘{...}’
>   filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, 
> 3.0e+0}’ from ‘’ to ‘std::vector’
>
> but with the switch it all flies.
>
> I think I'll add that to the Rcpp-FAQ now.
>
> Note though that here I simply assigned PKG_CXXFLAGS which had been empty as
> the Rcpp plugin does not set it. Other plugins may, so you one may have
> append rather than overwrite.
>
> Dirk
>
> --
> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
> dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction -- extra argument to g++

2012-01-24 Thread Dirk Eddelbuettel

On 24 January 2012 at 14:46, Whit Armstrong wrote:
| using cxxfunction is there an easy (not using a custom plugin) way to
| add -std=c++0x to the g++ call?

The best way, I think, is to call a plugin and to modify it.

Quick example:


R> myplugin <- getPlugin("Rcpp")
R> myplugin$env$PKG_CXXFLAGS <- "-std=c++0x"
R> f <- cxxfunction(signature(), settings=myplugin, body='
+std::vector x = { 1.0, 2.0, 3.0 };  // fails without -std=c++0x
+return Rcpp::wrap(x);
+ ')
R> f()
[1] 1 2 3
R> 


If you don't use the modified settings, it'll blow up as the 'curly init' is
a new feature:

   filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by 
constructor, not by ‘{...}’
   filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, 
3.0e+0}’ from ‘’ to ‘std::vector’

but with the switch it all flies.

I think I'll add that to the Rcpp-FAQ now.

Note though that here I simply assigned PKG_CXXFLAGS which had been empty as
the Rcpp plugin does not set it. Other plugins may, so you one may have
append rather than overwrite.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] cxxfunction()

2010-07-22 Thread romain
Hi, 

See : 

http://www.murdoch-sutherland.com/Rtools/

This gives you compilers and tools that your os lacks.

Romain

Le 22 juil. 2010 à 01:17, param jeet  a écrit :

>  
> Hello,
> Which Rtool is required for this to run. I have installed Rcpp and inline 
> packages. what else I should have in Rtools
>  
> Param 
> 
> On Thu, Jul 22, 2010 at 9:59 AM, Davor Cubranic  wrote:
> On July 21, 2010 07:04:02 pm param jeet wrote:
> > Hello,
> >   Still got error:
> 
> Yes, 'verbose' won't fix anything, it just gives us more information
> about what is going on.
> 
> > *Compilation argument:
> >  **\\In-fs1\UserDocuments\PARAM~1.JEE\MYDOCU~1\R\R-211~1.1/bin/R* > e://in-fs1/UserDocuments/PARAM~1.JEE/MYDOCU~1/R/R-211~1.1/bin/R> *
> > CMD SHLIB file8616435.cpp
> > 'sh' is not recognized as an internal or external command,
> > operable program or batch file.*
> > **
> > *ERROR(s) during compilation: source code errors or compiler
> > configuration errors!*
> 
> There is your problem: R did not file a valid Unix shell (sh/bash). Do
> you have RTools installed and in the PATH?
> 
> Davor
> 
> ___
> Rcpp-devel mailing list
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-22 Thread param jeet
Hello,
Which Rtool is required for this to run. I have installed Rcpp and
inline packages. what else I should have in Rtools

Param

On Thu, Jul 22, 2010 at 9:59 AM, Davor Cubranic wrote:

> On July 21, 2010 07:04:02 pm param jeet wrote:
> > Hello,
> >   Still got error:
>
> Yes, 'verbose' won't fix anything, it just gives us more information
> about what is going on.
>
> > *Compilation argument:
> >  **\\In-fs1\UserDocuments\PARAM~1.JEE\MYDOCU~1\R\R-211~1.1/bin/R* > e://in-fs1/UserDocuments/PARAM~1.JEE/MYDOCU~1/R/R-211~1.1/bin/R> *
> > CMD SHLIB file8616435.cpp
> > 'sh' is not recognized as an internal or external command,
> > operable program or batch file.*
> > **
> > *ERROR(s) during compilation: source code errors or compiler
> > configuration errors!*
>
> There is your problem: R did not file a valid Unix shell (sh/bash). Do
> you have RTools installed and in the PATH?
>
> Davor
>
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-22 Thread param jeet
Hello,
  Still got error:

 fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
+  ' ,verbose = TRUE)
 >> Program source :
   1 : // includes from the plugin
   2 : #include 
   3 : #include 
   4 : #include 
   5 :
   6 :
   7 : // user includes
   8 :
   9 :
  10 : // declaration
  11 : extern "C" {
  12 : SEXP file8616435( SEXP x, SEXP y) ;
  13 : }
  14 :
  15 : // definition
  16 :
  17 : SEXP file8616435( SEXP x, SEXP y ){
  18 :
  19 : return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
  20 :
  21 : Rf_warning("your C++ program does not return anything");
  22 :  return R_NilValue ;
  23 : }
  24 :
  25 :
*Compilation argument:
 
**\\In-fs1\UserDocuments\PARAM~1.JEE\MYDOCU~1\R\R-211~1.1/bin/R*
* CMD SHLIB file8616435.cpp
'sh' is not recognized as an internal or external command,
operable program or batch file.*
**
*ERROR(s) during compilation: source code errors or compiler configuration
errors!*
Program source:
  1: // includes from the plugin
  2: #include 
  3: #include 
  4: #include 
  5:
  6:
  7: // user includes
  8:
  9:
 10: // declaration
 11: extern "C" {
 12: SEXP file8616435( SEXP x, SEXP y) ;
 13: }
 14:
 15: // definition
 16:
 17: SEXP file8616435( SEXP x, SEXP y ){
 18:
 19: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
 20:
 21: Rf_warning("your C++ program does not return anything");
 22:  return R_NilValue ;
 23: }
 24:
 25:
Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created!

Param

On Wed, Jul 21, 2010 at 8:19 PM, Davor Cubranic wrote:

> You should probably try 'verbose = TRUE'.
>
> Davor
>
> On July 21, 2010 06:44:05 am param jeet wrote:
> > Hello Mr. Romain,
> >   Thanks for replying. Yes it is window. How to check R is correctly
> > installed?
> > Even with verbose it does not work. It give the same error. I am
> > printing sessionInfo() result and cxxfunction with verbose below.
> [...]
> >  fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
> > + return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
> > + ' ,verbose = FALSE)
> > ERROR(s) during compilation: source code errors or compiler
> > configuration errors!
> [...]
>
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-22 Thread Davor Cubranic
On July 21, 2010 07:04:02 pm param jeet wrote:
> Hello,
>   Still got error:

Yes, 'verbose' won't fix anything, it just gives us more information 
about what is going on.

> *Compilation argument:
>  **\\In-fs1\UserDocuments\PARAM~1.JEE\MYDOCU~1\R\R-211~1.1/bin/R* e://in-fs1/UserDocuments/PARAM~1.JEE/MYDOCU~1/R/R-211~1.1/bin/R> *
> CMD SHLIB file8616435.cpp
> 'sh' is not recognized as an internal or external command,
> operable program or batch file.*
> **
> *ERROR(s) during compilation: source code errors or compiler
> configuration errors!*

There is your problem: R did not file a valid Unix shell (sh/bash). Do 
you have RTools installed and in the PATH?

Davor
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-21 Thread Davor Cubranic
You should probably try 'verbose = TRUE'.

Davor

On July 21, 2010 06:44:05 am param jeet wrote:
> Hello Mr. Romain,
>   Thanks for replying. Yes it is window. How to check R is correctly
> installed?
> Even with verbose it does not work. It give the same error. I am
> printing sessionInfo() result and cxxfunction with verbose below.
[...]
>  fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
> + return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
> + ' ,verbose = FALSE)
> ERROR(s) during compilation: source code errors or compiler
> configuration errors!
[...]
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-21 Thread param jeet
Hello Mr. Romain,
  Thanks for replying. Yes it is window. How to check R is correctly
installed?
Even with verbose it does not work. It give the same error. I am printing
sessionInfo() result and cxxfunction with verbose below.

*> sessionInfo()
*R version 2.11.1 (2010-05-31)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252
LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] inline_0.3.5
loaded via a namespace (and not attached):
[1] tools_2.11.1


 fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
+ ' ,verbose = FALSE)
ERROR(s) during compilation: source code errors or compiler configuration
errors!
Program source:
  1: // includes from the plugin
  2: #include 
  3: #include 
  4: #include 
  5:
  6:
  7: // user includes
  8:
  9:
 10: // declaration
 11: extern "C" {
 12: SEXP file4a313dd0( SEXP x, SEXP y) ;
 13: }
 14:
 15: // definition
 16:
 17: SEXP file4a313dd0( SEXP x, SEXP y ){
 18:
 19: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
 20:
 21: Rf_warning("your C++ program does not return anything");
 22:  return R_NilValue ;
 23: }
 24:
 25:
Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created!


Thanks
Param

On Wed, Jul 21, 2010 at 6:56 PM,  wrote:

>  Hello,
>
> Thanks for reposting here. Which operating system is this ? If windows, do
> you have Rtools properly installed ?
>
> Can you try to use the "verbose" argument of cxxfunction
>
> Romain
>
>
>
>
> Le 21 juil. 2010 à 02:34, param jeet  a écrit :
>
> Hello,
>
> I have to work with Rcpp interface. I have installed packages inline and
> Rcpp.
>
> When I use the function below, I get the error. Error is following function
> statement below.  How to sort out this problem?
>  I would appreciate your help.
>
>
> fx <- cxxfunction( signature( x = "numeric" ),
> + ' NumericVector xx(x); return wrap( std::accumulate( xx.begin(),
> xx.end(), 0.0 ) ) ; '
> + , plugin = "Rcpp")
>
> *ERROR(s) during compilation: source code errors or compiler configuration
> errors!*
>
> Program source:
> 1: // includes from the plugin
> 2:
> 3: #include 
> 4:
> 5:
> 6: #ifndef BEGIN_RCPP
> 7: #define BEGIN_RCPP
> 8: #endif
> 9:
> 10: #ifndef END_RCPP
> 11: #define END_RCPP
> 12: #endif
> 13:
> 14: using namespace Rcpp;
> 15:
> 16:
> 17: // user includes
> 18:
> 19:
> 20: // declaration
> 21: extern "C" {
> 22: SEXP file712b6459( SEXP x) ;
> 23: }
> 24:
> 25: // definition
> 26:
> 27: SEXP file712b6459( SEXP x ){
> 28: BEGIN_RCPP
> 29: NumericVector xx(x); return wrap( std::accumulate( xx.begin(),
> xx.end(), 0.0 ) ) ;
> 30: END_RCPP
> 31: }
> 32:
> 33:
> Error in compileCode(f, code, language = language, verbose = verbose) :
> Compilation ERROR, function(s)/method(s) not created!
>
>
> I would appreciate your help.
>
> Regards:
> Param
>
>
>
>
>  ___
> Rcpp-devel mailing list
>
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] cxxfunction()

2010-07-21 Thread romain
Hello, 

Thanks for reposting here. Which operating system is this ? If windows, do you 
have Rtools properly installed ?

Can you try to use the "verbose" argument of cxxfunction 

Romain




Le 21 juil. 2010 à 02:34, param jeet  a écrit :

> Hello,
>   
> I have to work with Rcpp interface. I have installed packages inline and 
> Rcpp. 
>  
> When I use the function below, I get the error. Error is following function 
> statement below.  How to sort out this problem?
> I would appreciate your help.
>  
>  
> fx <- cxxfunction( signature( x = "numeric" ),
> + ' NumericVector xx(x); return wrap( std::accumulate( xx.begin(), xx.end(), 
> 0.0 ) ) ; '
> + , plugin = "Rcpp")
> 
> ERROR(s) during compilation: source code errors or compiler configuration 
> errors!
> 
> Program source:
> 1: // includes from the plugin
> 2: 
> 3: #include 
> 4: 
> 5: 
> 6: #ifndef BEGIN_RCPP
> 7: #define BEGIN_RCPP
> 8: #endif
> 9: 
> 10: #ifndef END_RCPP
> 11: #define END_RCPP
> 12: #endif
> 13: 
> 14: using namespace Rcpp;
> 15: 
> 16: 
> 17: // user includes
> 18: 
> 19: 
> 20: // declaration
> 21: extern "C" {
> 22: SEXP file712b6459( SEXP x) ;
> 23: }
> 24: 
> 25: // definition
> 26: 
> 27: SEXP file712b6459( SEXP x ){
> 28: BEGIN_RCPP
> 29: NumericVector xx(x); return wrap( std::accumulate( xx.begin(), xx.end(), 
> 0.0 ) ) ; 
> 30: END_RCPP
> 31: }
> 32: 
> 33: 
> Error in compileCode(f, code, language = language, verbose = verbose) : 
> Compilation ERROR, function(s)/method(s) not created!
> 
>  
> I would appreciate your help.
>  
> Regards:
> Param
>  
>  
> 
> 
> ___
> Rcpp-devel mailing list
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
___
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel