Glad to help,
The SystemRequirements is for a package. I believe the example in the
gallery is intended to demonstrate a function where if you set the
CXX_FLAGS with:
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
And then compiled a single *.cpp file with Rcpp::sourceCpp("test.cpp")
I believe it should work fine. But for package purposes you want the
user to not have to care about setting flags manually.
It ultimately just comes down to context.
Regards,
Charles
On Wed, Jun 24, 2015 at 11:57 AM, Edwin van Leeuwen <edwinvanl at
gmail.com>
wrote:
> Thank you! I was missing the SystemRequirements. I guess it could be
> useful to add this to the example given here:
> http://gallery.rcpp.org/articles/simple-lambda-func-c++11/
>
> Cheers, Edwin
>
> On Wed, 24 Jun 2015 at 17:50 Charles Determan <cdetermanjr at
gmail.com>
> wrote:
>
>> Hi Edwin,
>>
>> If you look at the build output you will notice that the C++11 compiler
>> flag is not being used. I just created a small package using Rcpp11
and
>> your function and it worked without a problem. I can't give you a
specific
>> reason without seeing your package but there are some possibilities I
would
>> guess right away.
>>
>> 1. Make sure you are 'LinkingTo' Rcpp11 in your DESCRIPTION
>> 2. Unless you are using some custom Makevars file, you should set
>> 'SystemRequirements: C++11' in your DESCRIPTION
>>
>> Charles
>>
>> On Wed, Jun 24, 2015 at 10:07 AM, Edwin van Leeuwen <edwinvanl at
gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> I've just started using Rcpp and am trying to get cpp11 support
working.
>>> As
>>> suggested I added [[Rcpp:plugins(cpp11)]] to my source file and a
test
>>> function:
>>> // [[Rcpp::export]]
>>> int useCpp11() {
>>> auto x = 10;
>>> return x;
>>> }
>>>
>>> This works fine when using:
>>> sourceCpp(filename)
>>> from R, but I would like to be able to compile the package from the
>>> command
>>> line.
>>> R CMD build mypackage
>>> fails with the following error:
>>> R CMD build ../fluEvidenceSynthesis
>>> * checking for file ?../fluEvidenceSynthesis/DESCRIPTION? ... OK
>>> * preparing ?fluEvidenceSynthesis?:
>>> * checking DESCRIPTION meta-information ... OK
>>> * cleaning src
>>> * installing the package to process help pages
>>> -----------------------------------
>>> * installing *source* package ?fluEvidenceSynthesis? ...
>>> ** libs
>>> g++ -I/usr/share/R/include -DNDEBUG
>>>
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
>>>
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include" -fpic
-g
>>> -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
>>> -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp
-o
>>> RcppExports.o
>>> g++ -I/usr/share/R/include -DNDEBUG
>>>
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
>>>
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include" -fpic
-g
>>> -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
>>> -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c
rcpp_hello_world.cpp
>>> -o
>>> rcpp_hello_world.o
>>> rcpp_hello_world.cpp: In function ?int useCpp11()?:
>>> rcpp_hello_world.cpp:33:10: error: ?x? does not name a type
>>> auto x = 10;
>>> ^
>>> rcpp_hello_world.cpp:34:12: error: ?x? was not declared in this
scope
>>> return x;
>>> ^
>>> make: *** [rcpp_hello_world.o] Error 1
>>> ERROR: compilation failed for package ?fluEvidenceSynthesis?
>>> * removing ?/tmp/RtmpWdUduu/Rinst2b601aa285e9/fluEvidenceSynthesis?
>>> -----------------------------------
>>> ERROR: package installation failed
>>>
>>>
>>> Any help appreciated.
>>>
>>> Cheers, Edwin
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more,
see
>>> 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.
>>
>>
>>
[[alternative HTML version deleted]]