rglのインストール

rglはマウスでグリグリ動かせる3Dを提供してくれるRのパッケージです.

これをGCC4.7の環境でビルドしようとすると以下のようなエラーが出たので,解決法を調べました.

g++ -I/usr/include/R/ -DNDEBUG -DHAVE_PNG_H -I/usr/include/libpng15 -DHAVE_FREETYPE -Iext/ftgl -I/usr/include/freetype2 -Iext -I/usr/local/include   -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2  -c PlaneSet.cpp -o PlaneSet.o
In file included from scene.h:9:0,
                 from PlaneSet.hpp:4,
                 from PlaneSet.cpp:1:
types.h: In instantiation of ‘ARRAY<T>::ARRAY(int, SRC*) [with SRC = double; T = float]’:
PlaneSet.cpp:17:32:   required from here
types.h:98:5: error: ‘copy’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/vector:61:0,
                 from scene.h:10,
                 from PlaneSet.hpp:4,
                 from PlaneSet.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:444:5: note: ‘template<class _II, class _OI> _OI std::copy(_II, _II, _OI)’ declared here, later in the translation unit
make: *** [PlaneSet.o] Error 1
ERROR: compilation failed for package ‘rgl’
* removing ‘/home/t2gmon/R/x86_64-unknown-linux-gnu-library/2.15/rgl’

CXXFLAGSに-fpermissiveを追加するとビルドが通りそうです.
http://gcc.gnu.org/gcc-4.7/porting_to.html
にも書かれています.

そして,install.packages時のCXXFLAGSを変更するためには,~/.R/MakevarsにCXXFLAGS+="-fpermissive"を追加するだけでいいみたいです.
http://stackoverflow.com/questions/8660990/changing-cxxflags-in-r-cmd-install-for-developing-r-packages


以上の作業でビルドができるようになりました.