2. 6. src/Makevarsへの追記
ビルドオプションの変数を追記する. ヘッダファイルの場所はsrcの位置からの相対パス
で指定できる.
## combine with standard arguments for R
PKG_CPPFLAGS = -I../inst/include
PKG_LIBS += $(RCPP_LDFLAGS)
※Writing R Extentions
http://cran.r-project.org/doc/manuals/R-exts.pdf
の説明
The most common use of a ‘Makevars’ file is to set additional preprocessor options (for
example include paths) for C/C++ files via PKG_CPPFLAGS, and additional compiler
flags by
setting PKG_CFLAGS, PKG_CXXFLAGS, PKG_FFLAGS or PKG_FCFLAGS, for C,
C++, FORTRAN
or Fortran 9x respectively (see Section 5.5 [Creating shared objects], page 101).
NB: Include paths are preprocessor options, not compiler options, and must be set in
PKG_CPPFLAGS as otherwise platform-specific paths (e.g. ‘-I/usr/local/include’) will
take
precedence.
7. Clean and Rebuild
4と同じようにRに公開したいfunctionが公開出来る形態でビルドが完了する.
パッケージを作成する際に, 他のパッケージで用いられているC++の関数を使用したい
場合がある.
1. 被呼び出し関数の作成
以下のようなソースファイルを持つRcppを使ったパッケージRcppMyLib1をRStudioに
より作成・ビルドする.
hoge(), fuga()はrとcppの関数として公開される.
cppの関数として公開されるとは, inst/include直下にヘッダファイルが作成されるとい
うことである.