# Problems building a package for R



## nv05 (Jan 26, 2011)

Not sure if this is the correct forum, but I thought someone might have had a similar issue.

I'm trying to build the package rgl for the R statistics suite on FreeBSD 8.1 on and amd64.  The software compiles, but I think it is linked to the incorrect library....


```
# sudo R CMD INSTALL /tmp/rgl (or env MAKE=gmake R CMD INSTALL)
* installing to library '/usr/local/lib/R/library'
* installing *source* package 'rgl' ...
checking for gcc... gcc45 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc45 -std=gnu99 accepts -g... yes
checking for gcc45 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... cpp
checking for gcc... (cached) gcc45 -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc45 -std=gnu99 accepts -g... (cached) yes
checking for gcc45 -std=gnu99 option to accept ISO C89... (cached) none needed
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
test: xno: unexpected operator
checking for X... libraries /usr/local/lib, headers /usr/local/include
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glEnd in -lGL... yes
checking for gluProject in -lGLU... yes
checking for freetype-config... yes
configure: using Freetype and FTGL
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++45 -I/usr/local/lib/R/include -DHAVE_PNG_H -I/usr/local/include/libpng -I/usr/local/include
-DHAVE_FREETYPE -Iext/ftgl -I/usr/local/include/freetype2 -I/usr/local/include -Iext -I/usr/local/include 
-O2 -pipe -Wl,-rpath=/usr/local/lib/gcc45 -fno-strict-aliasing -fpic  -O2 -pipe -Wl,
-rpath=/usr/local/lib/gcc45 -fno-strict-aliasing -c BBoxDeco.cpp -o BBoxDeco.o
...
...
g++45 -shared -L/usr/local/lib -o rgl.so BBoxDeco.o Background.o Color.o Disposa
ble.o Light.o LineSet.o LineStripSet.o Material.o PointSet.o PrimitiveSet.o Quad
Set.o RenderContext.o Shape.o SphereMesh.o SphereSet.o SpriteSet.o String.o Surf
ace.o TextSet.o Texture.o Viewpoint.o api.o assert.o callbacks.o device.o devicemanager.o
fps.o ftgl.o geom.o gl2ps.o glErrors.o glgui.o gui.o init.o osxgui.o osxlib.o par3d.o
pixmap.o render.o rglmath.o rglview.o scene.o select.o win32gui.o win32lib.o x11gui.o
x11lib.o -lGLU -lGL -L/usr/local/lib -lpng -lz -lm -L/usr/local/lib -lX11 -L/usr/local/lib
-lfreetype -lz -L/usr/local/lib/R/lib -lR
installing to /usr/local/lib/R/library/rgl/libs
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rgl', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared library '/usr/local/lib/R/library/rgl/libs/rgl.so':
  /usr/lib/libstdc++.so.6: version GLIBCXX_3.4.14 required by /usr/local/lib/R/library/rgl/libs/rgl.so not found
ERROR: loading failed
* removing '/usr/local/lib/R/library/rgl'
```

I have a few versions of libstdc, but I don't know how to know which is registered as 3.4.14:


```
# ldconfig -r | grep std
        88:-lstdc++.6 => /usr/lib/libstdc++.so.6
        357:-lgstdataprotocol-0.10.0 => /usr/local/lib/libgstdataprotocol-0.10.so.0
        1005:-lstdc++.6 => /usr/local/lib/gcc/x86_64-portbld-freebsd8.1/3.4.6/libstdc++.so.6
        1007:-lstdc++.6 => /usr/local/lib/gcc44/libstdc++.so.6
        1014:-lstdc++.6 => /usr/local/lib/gcc45/libstdc++.so.6
```

I'm thinking I need to add a library to the configure options so that it can find the library it is looking for, but I'm not sure and my first attempts are not working.  Any hints?

Thanks.


----------



## SirDice (Jan 26, 2011)

Porter's Handbook


----------



## clschmaltz (Jan 26, 2011)

Your R was compiled with a 4.5 gcc rather than 3.4 so add at least:

```
libstdc++.so.6  gcc45/libstdc++.so.6
```
to /etc/libmap.conf (http://www.freebsd.org/doc/en_US.ISO8859-1/articles/custom-gcc/article.html).

Or you could just install the newest R 2.12.1 without ports which works fine, and with rgl.


----------



## nv05 (Jan 27, 2011)

Adding the library to libmap.conf fixed the problem.  Much less work than I thought I'd be doing.  Thanks for the links.


----------

