can't install packages on ubuntu 20.04

Hello,I'm on ubuntu 20.04 and I try to install a package in Rstudio after installing Rstudio, but I always get this error :

R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("FactoMineR")
Installing package into ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘nloptr’, ‘pbkrtest’, ‘lme4’, ‘car’

trying URL 'https://cloud.r-project.org/src/contrib/nloptr_2.0.3.tar.gz'
Content type 'application/x-gzip' length 2219877 bytes (2.1 MB)
==================================================
downloaded 2.1 MB

trying URL 'https://cloud.r-project.org/src/contrib/pbkrtest_0.5.2.tar.gz'
Content type 'application/x-gzip' length 75295 bytes (73 KB)
==================================================
downloaded 73 KB

trying URL 'https://cloud.r-project.org/src/contrib/lme4_1.1-31.tar.gz'
Content type 'application/x-gzip' length 2947739 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/car_3.1-1.tar.gz'
Content type 'application/x-gzip' length 578902 bytes (565 KB)
==================================================
downloaded 565 KB

trying URL 'https://cloud.r-project.org/src/contrib/FactoMineR_2.7.tar.gz'
Content type 'application/x-gzip' length 2831910 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++14 accepts -g... yes
checking for g++ -std=gnu++14 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ -std=gnu++14 accepts -g... (cached) yes
checking for g++ -std=gnu++14 option to enable C++11 features... (cached) none needed
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... yes
checking for pkg-config checking NLopt version... insufficient: NLopt 2.7.0 or later is preferred.
checking for cmake... /usr/bin/cmake
using NLopt via local cmake build on x86_64 
set CMAKE_BIN=/usr/bin/cmake
set CC=gcc
set CFLAGS= -fpic -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
set LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- NLopt version 2.7.1
-- Looking for getopt.h
-- Looking for getopt.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for getpid
-- Looking for getpid - found
-- Looking for syscall
-- Looking for syscall - found
-- Looking for isinf
-- Looking for isinf - found
-- Looking for isnan
-- Looking for isnan - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for qsort_r
-- Looking for qsort_r - found
-- Looking for time
-- Looking for time - found
-- Looking for copysign
-- Looking for copysign - found
-- Looking for getopt
-- Looking for getopt - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of uint32_t
-- Check size of uint32_t - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Looking for sqrt in m
-- Looking for sqrt in m - found
-- Looking for fpclassify
-- Looking for fpclassify - TRUE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE - Success
-- Performing Test HAVE_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE - Failed
-- Looking for __cplusplus
-- Looking for __cplusplus - found
-- Performing Test SUPPORTS_STDCXX11
-- Performing Test SUPPORTS_STDCXX11 - Success
-- Performing Test HAS_FPIC
-- Performing Test HAS_FPIC - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt-build
Scanning dependencies of target generate-cpp
Scanning dependencies of target generate-fortran
[  1%] Generating nlopt.hpp
[  3%] Generating nlopt.f
[  3%] Built target generate-fortran
[  3%] Built target generate-cpp
Scanning dependencies of target nlopt
[  5%] Building C object CMakeFiles/nlopt.dir/src/algs/direct/direct_wrap.c.o
[  7%] Building C object CMakeFiles/nlopt.dir/src/algs/direct/DIRect.c.o
[  9%] Building C object CMakeFiles/nlopt.dir/src/algs/direct/DIRserial.c.o
[ 11%] Building C object CMakeFiles/nlopt.dir/src/algs/direct/DIRsubrout.c.o
[ 13%] Building C object CMakeFiles/nlopt.dir/src/algs/cdirect/cdirect.c.o
[ 15%] Building C object CMakeFiles/nlopt.dir/src/algs/cdirect/hybrid.c.o
[ 17%] Building C object CMakeFiles/nlopt.dir/src/algs/praxis/praxis.c.o
[ 19%] Building C object CMakeFiles/nlopt.dir/src/algs/luksan/plis.c.o
[ 21%] Building C object CMakeFiles/nlopt.dir/src/algs/luksan/plip.c.o
[ 23%] Building C object CMakeFiles/nlopt.dir/src/algs/luksan/pnet.c.o
[ 25%] Building C object CMakeFiles/nlopt.dir/src/algs/luksan/mssubs.c.o
[ 27%] Building C object CMakeFiles/nlopt.dir/src/algs/luksan/pssubs.c.o
[ 29%] Building C object CMakeFiles/nlopt.dir/src/algs/crs/crs.c.o
[ 31%] Building C object CMakeFiles/nlopt.dir/src/algs/mlsl/mlsl.c.o
[ 33%] Building C object CMakeFiles/nlopt.dir/src/algs/mma/mma.c.o
[ 35%] Building C object CMakeFiles/nlopt.dir/src/algs/mma/ccsa_quadratic.c.o
[ 37%] Building C object CMakeFiles/nlopt.dir/src/algs/cobyla/cobyla.c.o
[ 39%] Building C object CMakeFiles/nlopt.dir/src/algs/newuoa/newuoa.c.o
[ 41%] Building C object CMakeFiles/nlopt.dir/src/algs/neldermead/nldrmd.c.o
[ 43%] Building C object CMakeFiles/nlopt.dir/src/algs/neldermead/sbplx.c.o
[ 45%] Building C object CMakeFiles/nlopt.dir/src/algs/auglag/auglag.c.o
[ 47%] Building C object CMakeFiles/nlopt.dir/src/algs/bobyqa/bobyqa.c.o
[ 49%] Building C object CMakeFiles/nlopt.dir/src/algs/isres/isres.c.o
[ 50%] Building C object CMakeFiles/nlopt.dir/src/algs/slsqp/slsqp.c.o
[ 52%] Building C object CMakeFiles/nlopt.dir/src/algs/esch/esch.c.o
[ 54%] Building C object CMakeFiles/nlopt.dir/src/api/general.c.o
[ 56%] Building C object CMakeFiles/nlopt.dir/src/api/options.c.o
[ 58%] Building C object CMakeFiles/nlopt.dir/src/api/optimize.c.o
[ 60%] Building C object CMakeFiles/nlopt.dir/src/api/deprecated.c.o
[ 62%] Building C object CMakeFiles/nlopt.dir/src/api/f77api.c.o
[ 64%] Building C object CMakeFiles/nlopt.dir/src/util/mt19937ar.c.o
[ 66%] Building C object CMakeFiles/nlopt.dir/src/util/sobolseq.c.o
[ 68%] Building C object CMakeFiles/nlopt.dir/src/util/timer.c.o
[ 70%] Building C object CMakeFiles/nlopt.dir/src/util/stop.c.o
[ 72%] Building C object CMakeFiles/nlopt.dir/src/util/redblack.c.o
[ 74%] Building C object CMakeFiles/nlopt.dir/src/util/qsort_r.c.o
[ 76%] Building C object CMakeFiles/nlopt.dir/src/util/rescale.c.o
[ 80%] Building CXX object CMakeFiles/nlopt.dir/src/algs/stogo/global.cc.o
[ 80%] Building CXX object CMakeFiles/nlopt.dir/src/algs/stogo/linalg.cc.o
[ 82%] Building CXX object CMakeFiles/nlopt.dir/src/algs/stogo/local.cc.o
[ 84%] Building CXX object CMakeFiles/nlopt.dir/src/algs/stogo/stogo.cc.o
[ 86%] Building CXX object CMakeFiles/nlopt.dir/src/algs/stogo/tools.cc.o
[ 88%] Building CXX object CMakeFiles/nlopt.dir/src/algs/ags/evolvent.cc.o
[ 90%] Building CXX object CMakeFiles/nlopt.dir/src/algs/ags/solver.cc.o
[ 92%] Building CXX object CMakeFiles/nlopt.dir/src/algs/ags/local_optimizer.cc.o
[ 94%] Building CXX object CMakeFiles/nlopt.dir/src/algs/ags/ags.cc.o
[ 96%] Linking CXX static library libnlopt.a
[100%] Built target nlopt
[  1%] Built target generate-cpp
[ 98%] Built target nlopt
[100%] Built target generate-fortran
Install the project...
-- Install configuration: "Release"
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/pkgconfig/nlopt.pc
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/include/nlopt.h
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/include/nlopt.hpp
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/include/nlopt.f
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/libnlopt.a
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/cmake/nlopt/NLoptLibraryDepends.cmake
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/cmake/nlopt/NLoptLibraryDepends-release.cmake
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/cmake/nlopt/NLoptConfig.cmake
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/lib/cmake/nlopt/NLoptConfigVersion.cmake
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/share/man/man3/nlopt.3
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/share/man/man3/nlopt_minimize.3
-- Installing: /tmp/RtmpqxNfAU/R.INSTALL1aa6f68976f05/nloptr/src/nlopt/share/man/man3/nlopt_minimize_constrained.3
mv: cannot move 'nlopt/lib' to a subdirectory of itself, 'nlopt/lib/lib'
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include  -I'/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/testthat/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c init_nloptr.c -o init_nloptr.o
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include  -I'/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/testthat/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include  -I'/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/testthat/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include  -I'/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/testthat/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-a3XuZ5/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath nlopt/lib/libnlopt.a -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/lme4’
Warning in install.packages :
  installation of package ‘lme4’ had non-zero exit status
ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
* removing ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/pbkrtest’
Warning in install.packages :
  installation of package ‘pbkrtest’ had non-zero exit status
ERROR: dependencies ‘pbkrtest’, ‘lme4’ are not available for package ‘car’
* removing ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/car’
Warning in install.packages :
  installation of package ‘car’ had non-zero exit status
ERROR: dependency ‘car’ is not available for package ‘FactoMineR’
* removing ‘/home/lilia/R/x86_64-pc-linux-gnu-library/4.2/FactoMineR’
Warning in install.packages :
  installation of package ‘FactoMineR’ had non-zero exit status

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

Thanks in advance for your help.

You are missing these two system libraries, try installing them with this command on a system terminal.

sudo apt install libblas-dev libopenblas-base libopenblas-dev liblapack-dev liblapack3
1 Like

Hello,
I tried what you said and I was successfully able to install the package after that.Thank you very much for your help and have a wonderful day;)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.