upgrade R – F77 cause compilation error

October 20, 2010
By

(This article was first published on YGC » R, and kindly contributed to R-bloggers)

I try to compile the source code of R 2.12 on CentOS, but it throw an error when trying to install *cluster*.

* installing *source* package ‘cluster’ ...
** libs
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c clara.c -o clara.o
g77   -fpic  -g -O2 -c daisy.f -o daisy.o
g77   -fpic  -g -O2 -c dysta.f -o dysta.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c fanny.c -o fanny.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c init.c -o init.o
g77   -fpic  -g -O2 -c meet.f -o meet.o
g77   -fpic  -g -O2 -c mona.f -o mona.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c pam.c -o pam.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c sildist.c -o sildist.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c spannel.c -o spannel.o
g77   -fpic  -g -O2 -c twins.f -o twins.o
gcc -std=gnu99 -shared -L/usr/local/lib -o cluster.so clara.o daisy.o dysta.o fanny.o init.o meet.o mona.o pam.o sildist.o spannel.o twins.o -L/usr/lib/gcc/i386-redhat-linux/3.4.6 -lg2c -lm
installing to /usr/local/lib/R/library/cluster/libs
** R
** data
**  moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/usr/local/lib/R/library/cluster/libs/cluster.so':
  /usr/local/lib/R/library/cluster/libs/cluster.so: undefined symbol: cl_daisy_
ERROR: loading failed
* removing ‘/usr/local/lib/R/library/cluster’
* restoring previous ‘/usr/local/lib/R/library/cluster’

The downloaded packages are in
        ‘/tmp/RtmpP1rf0B/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages("cluster") :
  installation of package 'cluster' had non-zero exit status


*cluster* was one of the recommended packages. The first idea came into my mind was not to install that package. This can be done by:

./configure --without-recommended-packages

But this did not solve the problem, and many recommended packages was not updated.
R/etc/Makeconf was very informative for figuring out what the cause is.

I switched the fortran compiler to gfortran instead of g77, and it’s very weird to find that gfortran was not install on CentOS by default. As I know, gfortran usually coexists with GCC4, which also cause some problems when compiling some old version of R packages.

After switch the fortran compiler to gfortran, the installation works.

* installing *source* package cluster ...
** libs
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c clara.c -o clara.o
gfortran   -fpic  -g -O2 -c daisy.f -o daisy.o
gfortran   -fpic  -g -O2 -c dysta.f -o dysta.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c fanny.c -o fanny.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c init.c -o init.o
gfortran   -fpic  -g -O2 -c meet.f -o meet.o
gfortran   -fpic  -g -O2 -c mona.f -o mona.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c pam.c -o pam.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c sildist.c -o sildist.o
gcc -std=gnu99 -I/usr/local/lib/R/include  -I/usr/local/include    -fpic  -g -O2 -c spannel.c -o spannel.o
gfortran   -fpic  -g -O2 -c twins.f -o twins.o
gcc -std=gnu99 -shared -L/usr/local/lib -o cluster.so clara.o daisy.o dysta.o fanny.o init.o meet.o mona.o pam.o sildist.o spannel.o twins.o -L/usr/lib/gcc/i386-redhat-linux/3.4.6 -lg2c -lm
installing to /usr/local/lib/R/library/cluster/libs
** R
** data
**  moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (cluster)

The downloaded packages are in
        /tmp/RtmpP1rf0B/downloaded_packages
Updating HTML index of packages in '.Library'

After install the newest version of R, we can use the following command to upgrade all installed packages hosted in CRAN and Bioconductor to the newest version as mention in a previous post.

update.packages(checkBuilt=TRUE, ask=FALSE)
source("http://bioconductor.org/biocLite.R")
update.packages(repos=biocinstallRepos(), ask=FALSE)

Related Posts

To leave a comment for the author, please follow the link and comment on his blog: YGC » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.