rlinuxcmakedebian-stretch

problem installing nloptr 2.0.0 on debian 9 with R 4.2.0 and cmake 3.23.1


on my machine debian 9 (stretch), i have installed R4.2.0 from source. i have problem to install nloptr 2.0.0 using syntax:

if (!require("nloptr", quietly = TRUE)) BiocManager::install("nloptr")

the error i get is:

/opt/R/4.2.0/lib/R/etc/Makeconf:177: recipe for target 'test-C-API.o' failed
make: *** [test-C-API.o] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/ezop/R/x86_64-pc-linux-gnu-library/4.2/nloptr’

The downloaded source packages are in
    ‘/tmp/Rtmpqk35gk/downloaded_packages’
Warning message:
In install.packages(...) :
  installation of package ‘nloptr’ had non-zero exit status

I have tried, also, to install it by copying compiled binaries i have found online, but then i have this error:

> library(nloptr)
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/ezop/R/x86_64-pc-linux-gnu-library/4.2/nloptr/libs/nloptr.so':
  /home/ezop/R/x86_64-pc-linux-gnu-library/4.2/nloptr/libs/nloptr.so: invalid ELF header

I have checked the header and machine info, but i dont know what to do next:

base) root@kanta:/home/ezop/R/x86_64-pc-linux-gnu-library/4.2# file /home/ezop/R/x86_64-pc-linux-gnu-library/4.2/nloptr/libs/nloptr.so
/home/ezop/R/x86_64-pc-linux-gnu-library/4.2/nloptr/libs/nloptr.so: Mach-O 64-bit x86_64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|NO_REEXPORTED_DYLIBS|HAS_TLV_DESCRIPTORS>
(base) root@kanta:/home/ezop/R/x86_64-pc-linux-gnu-library/4.2# uname -a
Linux kanta 4.9.0-18-amd64 #1 SMP Debian 4.9.303-1 (2022-03-07) x86_64 GNU/Linux

Solution

  • I was having the same problem a few minutes ago. I tried installing cmake and gfortran but with little success. I noticed, when I was trying install.packages("nloptr") for the last time, this error message: There are binary versions available but the source versions are later. Do you want to install from sources the package which needs compilation?.

    Jenny Bryan explains here that a simple "No" would do.

    I hope this is useful for you too.