#include <Rcpp11> file not found error
Asked Answered
A

1

6

I am attempting to use the Rcpp11 package in r from it's source over at:

devtools::install_github("Rcpp11/Rcpp11")

I read here: http://blog.r-enthusiasts.com/2014/05/27/disambiguating-rcpp11-and-rcpp/

that I can use include <Rcpp11> + using namespace Rcpp11 at the head of my .cpp file but I get this error upon sourcing:

 egfile.cpp:1:10: fatal error: 'Rcpp11' file not found
 #include <Rcpp11>
           ^
 1 error generated.

where egfile.cpp:

#include <Rcpp11>
using namespace Rcpp11;

// Below is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp 
// function (or via the Source button on the editor toolbar)

// For more on using Rcpp click the Help button on the editor toolbar

// [[Rcpp::export]]
int timesTwo(int x) {
   return x * 2;
}

Any help with this? or should I defer to the // [[Rcpp::plugins(cpp11)]] method ?

Update: using the attributes::sourceCpp()

devtools::install_github("Rcpp11/attributes")

then restart from a clean session:

library(Rcpp11)
attributes::sourceCpp("egfile.cpp") # in home directory.

I get:

In file included from file2c1e303c4ed6.cpp:1:
    In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp11:4:
    In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp.h:238:
    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:54:1: error: no member named 'Rf_pnorm' in the global namespace
RCPP_DPQ__2(norm,double mean = 0, double sd = 1, mean, sd )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:30:51: note: expanded from macro 'RCPP_DPQ__2'
#define RCPP_DPQ__2(__NAME__,PAR1,PAR2,VAL1,VAL2) RCPP_DPQ(__NAME__,RCPP_ECHO(RCPP_CONCAT(PAR1,PAR2)), RCPP_ECHO(RCPP_CONCAT(VAL1,VAL2)) )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:14:31: note: expanded from macro 'RCPP_DPQ'
decltype(sapply( x, ::Rf_p##__NAME__, VAL, lower, log ))                                          \
                 ~~^
                     <scratch space>:208:1: note: expanded from here
                 Rf_pnorm
                 ^
                     In file included from file2c1e303c4ed6.cpp:1:
                     In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp11:4:
                     In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp.h:238:
                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:54:1: error: no member named 'Rf_pnorm' in the global namespace
                 RCPP_DPQ__2(norm,double mean = 0, double sd = 1, mean, sd )
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:30:51: note: expanded from macro 'RCPP_DPQ__2'
                 #define RCPP_DPQ__2(__NAME__,PAR1,PAR2,VAL1,VAL2) RCPP_DPQ(__NAME__,RCPP_ECHO(RCPP_CONCAT(PAR1,PAR2)), RCPP_ECHO(RCPP_CONCAT(VAL1,VAL2)) )
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:16:29: note: expanded from macro 'RCPP_DPQ'
                 return sapply( x, ::Rf_p##__NAME__, VAL, lower, log ) ;                                                      \
                                ~~^
                                    <scratch space>:208:1: note: expanded from here
                                Rf_pnorm
                                ^
                                    In file included from file2c1e303c4ed6.cpp:1:
                                    In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp11:4:
                                    In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp.h:238:
                                    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:54:1: error: no member named 'Rf_qnorm' in the global namespace
                                RCPP_DPQ__2(norm,double mean = 0, double sd = 1, mean, sd )
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:30:51: note: expanded from macro 'RCPP_DPQ__2'
                                #define RCPP_DPQ__2(__NAME__,PAR1,PAR2,VAL1,VAL2) RCPP_DPQ(__NAME__,RCPP_ECHO(RCPP_CONCAT(PAR1,PAR2)), RCPP_ECHO(RCPP_CONCAT(VAL1,VAL2)) )
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:20:31: note: expanded from macro 'RCPP_DPQ'
                                decltype(sapply( x, ::Rf_q##__NAME__, VAL, lower, log ))                                          \
                                                 ~~^
                                                     <scratch space>:208:1: note: expanded from here
                                                 Rf_qnorm
                                                 ^
                                                     In file included from file2c1e303c4ed6.cpp:1:
                                                     In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp11:4:
                                                     In file included from /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp.h:238:
                                                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:54:1: error: no member named 'Rf_qnorm' in the global namespace
                                                 RCPP_DPQ__2(norm,double mean = 0, double sd = 1, mean, sd )
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:30:51: note: expanded from macro 'RCPP_DPQ__2'
                                                 #define RCPP_DPQ__2(__NAME__,PAR1,PAR2,VAL1,VAL2) RCPP_DPQ(__NAME__,RCPP_ECHO(RCPP_CONCAT(PAR1,PAR2)), RCPP_ECHO(RCPP_CONCAT(VAL1,VAL2)) )
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp11/include/Rcpp/stats/stats.h:22:29: note: expanded from macro 'RCPP_DPQ'
                                                 return sapply( x, ::Rf_q##__NAME__, VAL, lower, log ) ;                                                      \
                                                                ~~^
                                                                    <scratch space>:208:1: note: expanded from here
                                                                Rf_qnorm
                                                                ^
                                                                    4 errors generated.
                                                                make: *** [file2c1e303c4ed6.o] Error 1
                                                                Error in dyn.load(basename(dynlib)) : 
                                                                    unable to load shared object '/private/var/folders/77/9nq5hj5d37b1rhbzdt0z3twr0000gn/T/RtmpcjWOsg/file2c1e303c4ed6.so':
                                                                    dlopen(/private/var/folders/77/9nq5hj5d37b1rhbzdt0z3twr0000gn/T/RtmpcjWOsg/file2c1e303c4ed6.so, 6): image not found
                                                                In addition: Warning message:
                                                                    running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB 'file2c1e303c4ed6.cpp'' had status 1 
Adaptation answered 29/5, 2014 at 6:43 Comment(2)
I have change the tag from rcpp to rcpp11.Easily
And there is no such thing as plugin=Rcpp11Easily
E
8

Presumably, you are trying to compile it from R Studio, which will use Rcpp::sourceCpp. You need the implementation of sourceCpp from the attributes package to generate the glue code for Rcpp11. attributes is available from github:

devtools::install_github("Rcpp11/attributes")

Then use this version to compile your file, i.e.

attributes::sourceCpp( "yourfile.cpp" )

Compiling an Rcpp11 file using Rstudio ui is something we have not yet dealt with, but something we identified as needed here

Easily answered 29/5, 2014 at 7:18 Comment(4)
Great guessing -- sorry for the ambiguity in my question. I have modified it accordingly. Please see the update as doing this brings about compile errors. Thanks for this early support, very excited about new header-only package.Adaptation
The new errors you mentioned were I believe fixed yesterday between builds 370 and 371. See travis-ci.org/Rcpp11/Rcpp11/builds There were a few errors in between, but the current snapshot builds.Easily
Also @user3686430 welcome on Stack Overflow. You'll get better answers if you identify yourself with your profile (e.g. instead of some random user name). If my answer suits you, please consider accepting it (the tick mark next at the top left).Easily
I have the identical problem to the original poster. Tried this solution. However, the function attributes::sourceCpp() fails with an error. These comments are from 2014, could you give me a heads up if this answer is still supposed to be valid? Thanks!Tinsel

© 2022 - 2024 — McMap. All rights reserved.