c++ - How to use RcppEigen -



c++ - How to use RcppEigen -

i beginner of c++, , want add together new bundle "crtrcppeigen" in c++ code rcppeigen, while thing wrong happened when run .bat file. help appreciated.

here c++ code function named "crtrcppeigen" want add together 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") homecoming (wrap(n*log(sse/n)+log(n)*p)); if(criteria=="k2") homecoming (wrap(n*log(sse/n)+(2*p*ny*n+ny*(ny+1))/n-2/n+n+2)); }

here 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

package: crtrcppeigen type: bundle 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 bundle windows binary.bat file is:

rcmd install --build crtrcppeigen pause

the build crtrcppeigen bundle 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

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 run build crtrcppeigen bundle windows binary.bat, error occurs:

* installing *source* bundle '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 alternative "nodosfilewarning" turns off warning. consult user's guide more details 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 alternative "nodosfilewarning" turns off warning. consult user's guide more details 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 bundle 'crtrcppeigen' * removing 'c:/users/ljh/documents/crtrcppeigen.rcheck/crtrcppeigen'

but rcpp bundle under status works. guess wrong c++ code.

your error

crtrcppeigen.cpp:3:20: fatal error: rcpp.h : no such file or directory

which should not happen appear have linkingto: rcpp in description.

to check, did on 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 , info ... making help files ... done. farther steps described in './quicktest/read-and-delete-me'. adding rcppeigen settings >> added imports: rcpp, rcppeigen >> added linkingto: rcpp, rcppeigen >> added usedynlib directive namespace >> added makevars file >> added makevars.win file >> added illustration src file using eigen classes >> invoked rcpp::compileattributes create wrappers r>

followed direct installation:

r> install.packages("quicktest", repos=null, type="source") installing bundle ‘c:/opt/r-library’ (as ‘lib’ unspecified) * installing *source* bundle '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 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 c:/opt/r-library/quicktest/libs/x64 ** r ** preparing bundle lazy loading ** help warning: c:/temp/quicktest/man/quicktest-package.rd:32: text must in section warning: c:/temp/quicktest/man/quicktest-package.rd:33: text must in section *** installing help indices ** building bundle indices ** testing if installed bundle can loaded *** arch - i386 *** arch - x64 * done (quicktest) r>

as can see works expected suggest compare empty skeleton bundle yours.

fwiw "usually" work on command-line did there looks fine too. said, r path entries @ end , manuals strongly suggest place them @ front.

c++ windows r eigen rcpp

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -