Search code examples
rcentosiconvlibiconv

Installation of R fails because of "undefined reference to `libiconv'"


I have problem with the installation of R 3.5.1. Although I have defined the path of the library "libiconv" in "cshrc", the installation fails with following message:

-L"../../lib" -lRblas -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4 -lgfortran -lm   -lreadline  -lpcre -llzma -lbz2 -lz -lrt -ldl -lm
platform.o: In function `do_eSoftVersion':
/opt/local/rstudio/R-3.5.1/src/main/platform.c:3088: undefined reference to `_libiconv_version'
sysutils.o: In function `Riconv':
/opt/local/rstudio/R-3.5.1/src/main/sysutils.c:799: undefined reference to `libiconv'
/opt/local/rstudio/R-3.5.1/src/main/sysutils.c:799: undefined reference to `libiconv'
/opt/local/rstudio/R-3.5.1/src/main/sysutils.c:799: undefined reference to `libiconv'
/opt/local/rstudio/R-3.5.1/src/main/sysutils.c:799: undefined reference to `libiconv'
sysutils.o: In function `Riconv_close':
 ...

BTW, I do not have root privilege.

After 2 days of searching, I could not find the reason.

Any help would be appreciated.


Solution

  • You seem to be using a glibc system (witnesses: a compiler which targets x86_64-redhat-linux, and the tag centos that you set).

    On a glibc system, you don't need GNU libiconv, because glibc has a full-featured iconv facility already included. So just uninstall libiconv, then rebuild R from scratch (make distclean; configure; make).