0

I am unable to install "mclust" R package on my Ubuntu 16.04. I have a following issue:

> install.packages("mclust")

>Installing package into ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.4’
>(as ‘lib’ is unspecified)
>trying URL 'https://cloud.r-project.org/src/contrib/mclust_5.4.2.tar.gz'
>Content type 'application/x-gzip' length 2699941 bytes (2.6 MB)
>==================================================
>downloaded 2.6 MB

>* installing *source* package ‘mclust’ ...
>** package ‘mclust’ successfully unpacked and MD5 sums checked
>** libs
>gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
>gfortran   -fpic  -g -O2 -fstack-protector-strong  -c mclust.f -o mclust.o
>gfortran   -fpic  -g -O2 -fstack-protector-strong  -c mclustaddson.f -o mclustaddson.o
>g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o mclust.so init.o mclust.o mclustaddson.o -llapack -lblas -lgfortran
-lm -lquadmath -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
>/usr/bin/x86_64-linux-gnu-ld: /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a(memory.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
>/usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a: error adding symbols: Bad value
>collect2: error: ld returned 1 exit status
>/usr/share/R/share/make/shlib.mk:6: recipe for target 'mclust.so' failed
>make: *** [mclust.so] Error 1
>ERROR: compilation failed for package ‘mclust’
>* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.4/mclust’
>Warning in install.packages :
>  installation of package ‘mclust’ had non-zero exit status

>The downloaded source packages are in
>   ‘/tmp/Rtmppg0XWs/downloaded_packages’

>sessionInfo()

>R version 3.4.4 (2018-03-15)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Ubuntu 16.04.5 LTS

>atrix products: default
>BLAS: /usr/lib/libblas/libblas.so.3.6.0
>LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

>locale:
> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=ru_RU.UTF-8       
> [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=ru_RU.UTF-8    LC_MESSAGES=en_US.UTF-8   
> [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
>[10] LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C       

>attached base packages:
>[1] stats     graphics  grDevices utils     datasets  methods   base     

>loaded via a namespace (and not attached):
>[1] compiler_3.4.4 tools_3.4.4    yaml_2.2.0

I have tried updating libgfortran and gcc-6 to the latest version, running apt-get update and upgrade. Thank you in advance for your help.

Edit: As per request of Norbert: Output of dpkg -S /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a

dpkg-query: no path found matching pattern /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a

Although, folder /usr/lib/gcc/x86_64-linux-gnu/6/ contains a link to /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a Output for dpkg -S /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a

libgfortran-5-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a

Edit2: Moving the /usr/lib/gcc/x86_64-linux-gnu/6/ to a different location results in a following error:

Installing package into ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)

trying URL 'https://cloud.r-project.org/src/contrib/mclust_5.4.2.tar.gz'

Content type 'application/x-gzip' length 2699941 bytes (2.6 MB)

==================================================

downloaded 2.6 MB



* installing *source* package ‘mclust’ ...

** package ‘mclust’ successfully unpacked and MD5 sums checked

** libs

gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o

gcc: error trying to exec 'cc1': execvp: No such file or directory

/usr/lib/R/etc/Makeconf:162: recipe for target 'init.o' failed

make: *** [init.o] Error 1

ERROR: compilation failed for package ‘mclust’

* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5/mclust’

Warning in install.packages :

  installation of package ‘mclust’ had non-zero exit status



The downloaded source packages are in

‘/tmp/RtmpU0X2uP/downloaded_packages’

Edit3: I have also tried to update R to 3.5.2. Error message remains the same, here is the new sessioinfo:

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                   LC_TIME=ru_RU.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=ru_RU.UTF-8        LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
 [10] LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8  LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] BiocManager_1.30.4 compiler_3.5.2     tools_3.5.2        yaml_2.2.0        

Edit4: I also have a very similiar error while installing igraph package:

/usr/bin/x86_64-linux-gnu-ld: /usr/lib/gcc/x86_64-linux- gnu/6/libgfortran.a(etime.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'igraph.so' failed
make: *** [igraph.so] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5/igraph’
Warning in install.packages :
  installation of package ‘igraph’ had non-zero exit status

Edit5: I have also tried running install.packages("mclust",lib="/home/ivan/R/x86_64-pc-linux-gnu-library/3.5") through Rscript with sudo and it results in the same error.

  • Please add output of dpkg -S /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a to the question. I do not have such file on clean installation of 16.04 and R configured with my guide. So let's determine its package. – N0rbert Jan 16 at 21:09
  • Ok, I have done that. – I.N.Vlasov Jan 17 at 9:13
  • I can recommend to move the folder /usr/lib/gcc/x86_64-linux-gnu/6/ to other location and retry. – N0rbert Jan 17 at 12:12
  • Ok, I have also tried that. Output is too long for a comment field, put it in the body of question. – I.N.Vlasov Jan 18 at 9:44
  • I can't reproduce your issue. Have you ever upgraded your Ubuntu between versions (for example 12.04 -> 14.04 -> 16.04)? – N0rbert Jan 18 at 20:56
0

So in case somebody ever encounters the same problem - I have fixed it by removing gcc, r, and build essentials packages, then reinstalling them, then reinstalling R according to R 3.5.0 for Ubuntu, answer of @krlmlr.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.