upgrade R – F77 cause compilation error

[This article was first published on YGC » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: YGC » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)