User Tools

Site Tools


Howto R and netcdf library


The installed binary of libnetcdf shared library is not comaptible with the 32bit R package ncdf. The error message wile compiling it looks similar to the below output :

gcc -std=gnu99 -shared -o ncdf.o ncdf2.o ncdf3.o -L/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -L/usr/lib/x86_64-linux-gnu -lcurl -L/usr/lib/R/lib -lR
/usr/bin/ld: error: /usr/local/lib/libnetcdf.a(nc4attr.o): requires dynamic R_X86_64_PC32 reloc against 'strcmp' which may overflow at runtime; recompile with -fPIC


Configure libnetcdf from sources with CFLAGS=-fPIC and start normal installation.

cd ~/src
tar -xvf netcdf-4.3.0.tar.gz
cd netcdf-4.3.0.tar.gz
./configure CFLAGS=-fPIC
sudo make install
r/r-tutorials/rnetcdf.txt · Last modified: 2018/12/23 19:46 (external edit)