Greetings. I am attempting to add NetCDF libraries within R, and have failed. We have R version 2.8, and are running on a 64-bit Redhat Linux 2.6.18 kernel: Red Hat Enterprise Linux Client release 5.2 (Tikanga) Linux halfmoon.ncdc.noaa.gov 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:28:22 EST 2008 x86_64 x86_64 x86_64 GNU/Linux I have run the installation instructions found at "http://www.image.ucar.edu/Software/Netcdf/", but not successfully. I'm wondering if you can give some advice that will change our outcome? We've run "R CMD INSTALL --configure-args="-with-netcdf_incdir=/usr/local/netcdf-3.6.1/include -with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz" against NetCDF 3.6.1, 3.6.2, and 4.0 all with the same results. I think our being on a 64-bit Linux has to do with the failure. Can you confirm this? Outputs are below from the 64-bit system "halfmoon": [root at halfmoon local]# R --version R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU General Public License version 2. For more information about these matters see http://www.gnu.org/licenses/. Here is my output: [root at halfmoon local]# R CMD INSTALL --configure-args="-with-netcdf_incdir=/usr/local/netcdf-3.6.1/include -with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz * Installing to library '/usr/local/lib64/R/library' * Installing *source* package 'ncdf' ... checking for gcc... gcc -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 gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking /usr/local/netcdf-3.6.1/include/netcdf.h usability... yes checking /usr/local/netcdf-3.6.1/include/netcdf.h presence... yes checking for /usr/local/netcdf-3.6.1/include/netcdf.h... yes Using user-specified netCDF include dir=/usr/local/netcdf-3.6.1/include Found netcdf.h in: /usr/local/netcdf-3.6.1/include checking for /usr/local/netcdf-3.6.1/lib/libnetcdf.a... yes Using user-specified netCDF library dir=/usr/local/netcdf-3.6.1/lib Found netcdf library file libnetcdf.a in directory /usr/local/netcdf-3.6.1/lib configure: creating ./config.status config.status: creating R/load.R config.status: creating src/Makevars ** libs gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf2.c -o ncdf2.o gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf3.c -o ncdf3.o ncdf3.c: In function 'R_nc_get_vara_charvarid': ncdf3.c:221: warning: assignment discards qualifiers from pointer target type ncdf3.c: In function 'R_nc_get_vara_numvarid': ncdf3.c:267: warning: assignment discards qualifiers from pointer target type gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf.c -o ncdf.o ncdf.c: In function 'R_nc_ttc_to_nctype': ncdf.c:424: warning: implicit declaration of function 'exit' ncdf.c:424: warning: incompatible implicit declaration of built-in function 'exit' gcc -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf2.o ncdf3.o ncdf.o -L/usr/local/netcdf-3.6.1/lib -lnetcdf /usr/bin/ld: /usr/local/netcdf-3.6.1/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/netcdf-3.6.1/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 chmod: cannot access `/usr/local/lib64/R/library/ncdf/libs/*': No such file or directory ERROR: compilation failed for package 'ncdf' ** Removing '/usr/local/lib64/R/library/ncdf' Thanks in advance, Ken Schmidt National Climatic Data Center Asheville, NC 28801
NetCDF within R: installation assistance
2 messages · Ken Schmidt, Brian Ripley
On Tue, 23 Dec 2008, Ken Schmidt wrote:
Greetings. I am attempting to add NetCDF libraries within R, and have failed. We have R version 2.8, and are running on a 64-bit Redhat Linux 2.6.18 kernel: Red Hat Enterprise Linux Client release 5.2 (Tikanga) Linux halfmoon.ncdc.noaa.gov 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:28:22 EST 2008 x86_64 x86_64 x86_64 GNU/Linux I have run the installation instructions found at "http://www.image.ucar.edu/Software/Netcdf/", but not successfully. I'm wondering if you can give some advice that will change our outcome? We've run "R CMD INSTALL --configure-args="-with-netcdf_incdir=/usr/local/netcdf-3.6.1/include -with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz" against NetCDF 3.6.1, 3.6.2, and 4.0 all with the same results. I think our being on a 64-bit Linux has to do with the failure. Can you confirm this?
No, it works successfully, as the CRAN check logs will confirm at http://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64/RNetCDF-00check.html You need a PIC library on x86_64 Linux: it is normal for use dynamic libraries (which are PIC), and that is the problem you need to address (with your RHEL support, not here).
Outputs are below from the 64-bit system "halfmoon": [root at halfmoon local]# R --version R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU General Public License version 2. For more information about these matters see http://www.gnu.org/licenses/. Here is my output: [root at halfmoon local]# R CMD INSTALL --configure-args="-with-netcdf_incdir=/usr/local/netcdf-3.6.1/include -with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz * Installing to library '/usr/local/lib64/R/library' * Installing *source* package 'ncdf' ... checking for gcc... gcc -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 gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking /usr/local/netcdf-3.6.1/include/netcdf.h usability... yes checking /usr/local/netcdf-3.6.1/include/netcdf.h presence... yes checking for /usr/local/netcdf-3.6.1/include/netcdf.h... yes Using user-specified netCDF include dir=/usr/local/netcdf-3.6.1/include Found netcdf.h in: /usr/local/netcdf-3.6.1/include checking for /usr/local/netcdf-3.6.1/lib/libnetcdf.a... yes Using user-specified netCDF library dir=/usr/local/netcdf-3.6.1/lib Found netcdf library file libnetcdf.a in directory /usr/local/netcdf-3.6.1/lib configure: creating ./config.status config.status: creating R/load.R config.status: creating src/Makevars ** libs gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf2.c -o ncdf2.o gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf3.c -o ncdf3.o ncdf3.c: In function 'R_nc_get_vara_charvarid': ncdf3.c:221: warning: assignment discards qualifiers from pointer target type ncdf3.c: In function 'R_nc_get_vara_numvarid': ncdf3.c:267: warning: assignment discards qualifiers from pointer target type gcc -std=gnu99 -I/usr/local/lib64/R/include -I/usr/local/netcdf-3.6.1/include -I/usr/local/include -fpic -g -O2 -c ncdf.c -o ncdf.o ncdf.c: In function 'R_nc_ttc_to_nctype': ncdf.c:424: warning: implicit declaration of function 'exit' ncdf.c:424: warning: incompatible implicit declaration of built-in function 'exit' gcc -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf2.o ncdf3.o ncdf.o -L/usr/local/netcdf-3.6.1/lib -lnetcdf /usr/bin/ld: /usr/local/netcdf-3.6.1/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/netcdf-3.6.1/lib/libnetcdf.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [ncdf.so] Error 1 chmod: cannot access `/usr/local/lib64/R/library/ncdf/libs/*': No such file or directory ERROR: compilation failed for package 'ncdf' ** Removing '/usr/local/lib64/R/library/ncdf' Thanks in advance, Ken Schmidt National Climatic Data Center Asheville, NC 28801
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595