I am beginner of C++, and I want to add a new package "CRTRCppEigen" in C++ code to RcppEigen, while some thing wrong happened when run some .bat file. Any help will be appreciated.
Here is the C++ code function named "CRTRCppEigen" i want to add to RcppEigen in file 'src':
#include < Rcpp.h >
#include < RcppEigen.h >
#include <Eigen/Dense>
#include <iostream>
#include <string>
using Eigen::MatrixXd;
using namespace std;
using namespace Rcpp;
using namespace RcppEigen;
using namespace Eigen;
RcppExport SEXP MatOp(SEXP Xr, SEXP Yr, SEXP Kr)
{
MatrixXd X = RcppEigen::as<MatrixXd>(Xr);
MatrixXd Y = RcppEigen::as<MatrixXd>(Yr);
string K = Rcpp::as<string>(Kr);
int n=X.rows();
int p=X.cols();
int nY=Y.cols();
MatrixXd I(n,n);
I.setIdentity(n,n);
double SSE=(Y.transpose()*(I-X*(X.transpose()*X).inverse()*X.transpose())*Y).determinant();
if(Criteria=="k1")
return (wrap(n*log(SSE/n)+log(n)*p));
if(Criteria=="k2")
return (wrap(n*log(SSE/n)+(2*p*nY*n+nY*(nY+1))/n-2/n+n+2));
}
here is the R code in file 'R'
RcppEigen.package.skeleton("CRTRCppEigen")
getwd()
#[1] "C:/Users/LJH/Documents"
CRTR <- function(Xr,Yr,criteriar) {
.Call('CRTRCppEigen',Xr,Yr,criteriar,PACKAGE = 'CRTRCppEigen')
}
prompt(CRTR)
The DESCRIPTION file is
Package: CRTRCppEigen
Type: Package
Title: RSS calculation based matrix operation
Version: 1.0
Date: 2014-10-22
Author: Junhui Li
Maintainer: Junhui Li<junhuili#cau.edu.cn>
Description: Residual sum of square
License: GPL (>= 2)
Imports: Rcpp (>= 0.11.3), RcppEigen (>= 0.3.2.2.0)
LinkingTo: Rcpp, RcppEigen
The build CRTRCppEigen package Windows Binary.bat file is:
Rcmd INSTALL --build CRTRCppEigen
PAUSE
The build CRTRCppEigen package Linux Source Code.bat file is:
Rcmd build CRTRCppEigen
pause
The install CRTRCppEigen package.bat file is:
Rcmd INSTALL CRTRCppEigen
PAUSE
The check CRTRCppEigen package.bat file is:
Rcmd check CRTRCppEigen
PAUSE
the environment variable is
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\Bin\;c:\Program Files\Intel\DMIX;C:\Program Files (x86)\Intel\Services\IPT\;C:\Program Files\SASHome\Secure;C:\Program Files\SASHome\x86\Secure;C:\Opt\MiKTeX2.9\miktex\bin\x64\;C:\Opt\MiKTeX2.9\miktex\bin\x64\;C:\Rtools\bin;C:\Rtools\gcc-4.6.3\bin;C:\R\R-3.1.1\bin\x64;C:\R\R-3.1.1\bin\i386;
while when i run build CRTRCppEigen package Windows Binary.bat, error occurs:
* installing *source* package 'CRTRCppEigen' ...
** libs
*** arch - i386
cygwin warning:
MS-DOS style path detected: C:/R/R-31~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-31~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -m32 -I"C:/R/R-31~1.1/include" -DNDEBUG -I"C:/Users/LJH/Documents/R/win-library/3.1/Rcpp/include" -I"C:/Users/LJH/Documents/R/win-library/3.1/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c CRTRCppEigen.cpp -o CRTRCppEigen.o
CRTRCppEigen.cpp:3:20: fatal error: Rcpp.h : No such file or directory
compilation terminated.
make: *** [CRTRCppEigen.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-31~1.1/etc/i386/Makeconf" -f "C:/R/R-31~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="CRTRCppEigen.dll" OBJECTS="CRTRCppEigen.o RcppExports.o rcppeigen_hello_world.o"' had status 2
cygwin warning:
MS-DOS style path detected: C:/R/R-31~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-31~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -m32 -I"C:/R/R-31~1.1/include" -DNDEBUG -I"C:/Users/LJH/Documents/R/win-library/3.1/Rcpp/include" -I"C:/Users/LJH/Documents/R/win-library/3.1/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c CRTRCppEigen.cpp -o CRTRCppEigen.o
CRTRCppEigen.cpp:3:20: fatal error: Rcpp.h : No such file or directory
compilation terminated.
make: *** [CRTRCppEigen.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-31~1.1/etc/i386/Makeconf" -f "C:/R/R-31~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="CRTRCppEigen.dll" OBJECTS="CRTRCppEigen.o RcppExports.o rcppeigen_hello_world.o" symbols.rds' had status 2
ERROR: compilation failed for package 'CRTRCppEigen'
* removing 'C:/Users/LJH/Documents/CRTRCppEigen.Rcheck/CRTRCppEigen'
but a Rcpp package under this condition works. So I guess something wrong with the C++ code.
Your error is
CRTRCppEigen.cpp:3:20: fatal error: Rcpp.h : No such file or directory
which should not happen as you appear to have LinkingTo: Rcpp in DESCRIPTION.
To check, I just did this on a Windows box:
R> setwd("c:/temp")
R> RcppEigen.package.skeleton(name="quicktest")
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './quicktest/Read-and-delete-me'.
Adding RcppEigen settings
>> added Imports: Rcpp, RcppEigen
>> added LinkingTo: Rcpp, RcppEigen
>> added useDynLib directive to NAMESPACE
>> added Makevars file
>> added Makevars.win file
>> added example src file using Eigen classes
>> invoked Rcpp::compileAttributes to create wrappers
R>
followed by a direct installation:
R> install.packages("quicktest", repos=NULL, type="source")
Installing package into ‘c:/opt/R-library’
(as ‘lib’ is unspecified)
* installing *source* package 'quicktest' ...
** libs
*** arch - i386
g++ -m32 -I"C:/opt/R-CURR~1/include" -DNDEBUG -I"c:/opt/R-library/Rcpp/include" -I"c:/opt/R-library/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
g++ -m32 -I"C:/opt/R-CURR~1/include" -DNDEBUG -I"c:/opt/R-library/Rcpp/include" -I"c:/opt/R-library/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c rcppeigen_hello_world.cpp -o rcppeigen_hello_world.o
g++ -m32 -shared -s -static-libgcc -o quicktest.dll tmp.def RcppExports.o rcppeigen_hello_world.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/opt/R-CURR~1/bin/i386 -lR
installing to c:/opt/R-library/quicktest/libs/i386
*** arch - x64
g++ -m64 -I"C:/opt/R-CURR~1/include" -DNDEBUG -I"c:/opt/R-library/Rcpp/include" -I"c:/opt/R-library/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
g++ -m64 -I"C:/opt/R-CURR~1/include" -DNDEBUG -I"c:/opt/R-library/Rcpp/include" -I"c:/opt/R-library/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c rcppeigen_hello_world.cpp -o rcppeigen_hello_world.o
g++ -m64 -shared -s -static-libgcc -o quicktest.dll tmp.def RcppExports.o rcppeigen_hello_world.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/opt/R-CURR~1/bin/x64 -lR
installing to c:/opt/R-library/quicktest/libs/x64
** R
** preparing package for lazy loading
** help
Warning: c:/TEMP/quicktest/man/quicktest-package.Rd:32: All text must be in a section
Warning: c:/TEMP/quicktest/man/quicktest-package.Rd:33: All text must be in a section
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (quicktest)
R>
As you can see it works as expected so I suggest you compare the empty skeleton package with yours.
FWIW I also "usually" work on the command-line so what you did there looks fine too. That said, your R PATH entries are at the end and the manuals somewhat strongly suggest to place them at the front.
Related
I install R (v. 4.2.2) in GNU Guix Linux-libre. But, after trying installation package 'Rcpp', I got error: std::__throw_bad_array_new_length().
> install.packages("Rcpp")
Installing package into ‘/home/guix/R/x86_64-unknown-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/src/contrib/Rcpp_1.0.10.tar.gz'
Content type 'application/x-gzip' length 2936173 bytes (2.8 MB)
==================================================
downloaded 2.8 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++14 -I"/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/include" -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c api.cpp -o api.o
In file included from /gnu/store/fyc3x8nd2ln090y4ng020rvspwl5pc78-gcc-12.2.0/include/c++/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
from /home/guix/.guix-profile/include/c++/bits/allocator.h:46,
from /home/guix/.guix-profile/include/c++/unordered_map:40,
from ../inst/include/Rcpp/platform/compiler.h:153,
from ../inst/include/Rcpp/r/headers.h:62,
from ../inst/include/RcppCommon.h:30,
from ../inst/include/Rcpp.h:27,
from api.cpp:26:
/home/guix/.guix-profile/include/c++/bits/new_allocator.h: In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*)’:
/home/guix/.guix-profile/include/c++/bits/new_allocator.h:125:20: error: ‘__throw_bad_array_new_length’ is not a member of ‘std’; did you mean ‘bad_array_new_length’?
125 | std::__throw_bad_array_new_length();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| bad_array_new_length
make: *** [/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/etc/Makeconf:178: api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/home/guix/R/x86_64-unknown-linux-gnu-library/4.2/Rcpp’
The downloaded source packages are in
‘/tmp/RtmptAJQ9x/downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status
The same error was after trying to install 'ggplot2'.
* installing *source* package ‘farver’ ...
** package ‘farver’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c ColorSpace.cpp -o ColorSpace.o
g++ -std=gnu++11 -I"/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c Comparison.cpp -o Comparison.o
g++ -std=gnu++11 -I"/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c Conversion.cpp -o Conversion.o
g++ -std=gnu++11 -I"/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c encode.cpp -o encode.o
In file included from /gnu/store/fyc3x8nd2ln090y4ng020rvspwl5pc78-gcc-12.2.0/include/c++/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
from /home/guix/.guix-profile/include/c++/bits/allocator.h:46,
from /home/guix/.guix-profile/include/c++/unordered_map:40,
from encode.h:4,
from encode.cpp:1:
/home/guix/.guix-profile/include/c++/bits/new_allocator.h: In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*)’:
/home/guix/.guix-profile/include/c++/bits/new_allocator.h:125:20: error: ‘__throw_bad_array_new_length’ is not a member of ‘std’; did you mean ‘bad_array_new_length’?
125 | std::__throw_bad_array_new_length();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| bad_array_new_length
make: *** [/gnu/store/kjd4gfz8frchb8n4ada2l6nssa9pnin6-r-minimal-4.2.2/lib/R/etc/Makeconf:178: encode.o] Error 1
ERROR: compilation failed for package ‘farver’
* removing ‘/home/guix/R/x86_64-unknown-linux-gnu-library/4.2/farver’
I think that is need to install package in GNU/Linux system that is essential for R, but I don't know what. This is my system:
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Guix System
Matrix products: default
BLAS/LAPACK: /gnu/store/xghpgl3fnr603z16vg7hldmpxygriqm2-openblas-0.3.20/lib/libopenblasp-r0.3.20.so
locale:
[1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
[3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8
[5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8
[7] LC_PAPER=en_US.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2 tcltk_4.2.2
Software info:
Linux Kernel: 4.14.83-1-MANJARO
R: 3.5.1
Rcpp: 1.0.0
g++ g++ (GCC) 8.2.1 20180831
I'm trying to install the later package from CRAN, but it fails due to a compilation error and I can't figure out whether there is something wrong with my own configuration or the package. The installation stops after the call
g++ -I"/usr/include/R/" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=1 -I"/home/karpfen/R-libs/Rcpp/include" -I"/usr/lib/R/library/BH/include" -D_FORTIFY_SOURCE=2 -fopenmp -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c timestamp_win32.cpp -o timestamp_win32.o
with the error message
make: *** No rule to make target '-fopenmp', needed by 'later.so'. Stop.
Rcpp and other packages depending on it work as expected. Is there anything that I could be doing wrong here? I tried reinstalling R + packages already, but no changes here.
Edit:
The first few lines of the installation output are
* installing *source* package ‘later’ ...
** package ‘later’ successfully unpacked and MD5 sums checked
Running configure script
Using CC=gcc
Using CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt
Using CPPFLAGS=-D_FORTIFY_SOURCE=2
C11-style threads.h support detected.
Edit2:
System information (from /etc/lsb-release)
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=18.0.0
DISTRIB_CODENAME=Illyria
DISTRIB_DESCRIPTION="Manjaro Linux"
I tried to install RcppEigen on amazon EC2 (on a t1.micro to
make sure It works) & ubuntu 13.04. I tried with both R version was 2.15.2 and 3.0, 32bit ubuntu and 64bit ubuntu. Any time I got the following:
root#ip-10-224-4-239:/home/ubuntu# R CMD INSTALL RcppEigen_0.3.1.2.1.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c RcppEigen.cpp -o RcppEigen.o
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c fastLm.cpp -o fastLm.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
make: *** [fastLm.o] Error 4
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/usr/local/lib/R/site-library/RcppEigen’
Anyone has an idea on how to get RcppEigen to run on EC2?
(Rcpp installs flawlessly....)
That looks like a "simple" out of memory issue.
C++ can be demanding as is, and complex template code (which Eigen surely is) demands even more resources. Simply try allocating more memory -- otherwise it is hard to kill g++.
I'm currently working on an R package which uses C++ code and includes external libraries (dlib, boost and an optimization library developed in the group). We're using Rcpp to integrate R and C++, but the problem is the package always fails to compile, and none of the similar questions I've found out there have worked for me.
The report generated by R CMD check is:
* installing *source* package 'IRTppExperimental' ...
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c test_multi.cpp -o test_multi.o
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o IRTppExperimental.dll tmp.def RcppExports.o rcpp_hello_world.o test_multi.o -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lRlapack -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lRblas IRTppExperimental.dll -L../src/include -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lR
g++.exe: error: IRTppExperimental.dll: No such file or directory
no DLL was created
ERROR: compilation failed for package 'IRTppExperimental'
* removing 'C:/Users/Camilo/Documents/UNAL/MIRT/Tests/Temps/IRTppExperimental.Rcheck/IRTppExperimental'
And the Makevars/Makevars.win files are as follows:
INCFOLDER = ../src/include
PKG_LIBS += $(LAPACK_LIBS) $(BLAS_LIBS) $(FPICFLAGS) $(SHLIB)
PKG_LIBS += -L$(INCFOLDER)
PKG_CXXFLAGS+=-I$(INCFOLDER)
CXXFLAGS+="-fno-stack-protector"
CXX_STD = CXX11
Lastly, the NAMESPACE file reads:
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp,sourceCpp)
useDynLib(IRTppExperimental)
All the c++ source files are inside the src folder, including the external libraries. The package was created using the Rcpp.package.skeleton function, and used the compileAtributes function to create the RcppExports source files.
EDIT: As pointed out by Coatless, here is github link of the project: https://github.com/SICSresearch/IRTpp/tree/Uni-Multi-Merging
$ export PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'`
$ export PKG_LIBS=`Rscript -e 'Rcpp:::LdFlags()'`
$ R CMD SHLIB my.cpp
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c my.cpp -o my.o
my.cpp:3:27: fatal error: RcppArmadillo.h: No such file or directory
compilation terminated.
make: *** [my.o] Error 1
My RcppArmadillo.h is under
$ locate -i RcppArmadillo.h
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h
I wonder how to specify its path to the compiler?
my.cpp looks like:
#include <RcppArmadillo.h>
#include <math.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
using namespace arma;
// [[Rcpp::export]]
...
My OS is Ubuntu 12.04. R is R version 3.1.0 (2014-04-10). I just installed Rcpp and RcppArmadillo, so I guess they are also the most recent ones.
Thanks and regards!
You cannot just R CMD SHLIB this file. Because you use Rcpp attributes, you need some code to be generated from Rcpp::depends and Rcpp::export.
You can either call sourceCpp( 'my.cpp' ) from R if you just want standalone use of the file or use various tools such as compileAttributes or devtools::load_all if this file is part of a package you are developping.
But R CMD SHLIB is not going to generate the extra code for you.
Something I have on my $PATH and find quite useful is this RcppScript script:
#!/usr/bin/Rscript
args <- commandArgs(TRUE)
if( "-v" %in% args ){
options( verbose = TRUE )
}
library(Rcpp)
sourceCpp( tail(args,1) )
So that you can do:
$ RcppScript my.cpp