I have a box with antiX, which is a Debian clone. I compiled and installed nlopt and still:
> install.packages("nloptr")
Installing package into ‘/home/stephen/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://utstat.toronto.edu/cran/src/contrib/nloptr_1.2.2.2.tar.gz'
Content type 'application/x-gzip' length 2450931 bytes (2.3 MB)
==================================================
downloaded 2.3 MB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
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 we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking nlopt.h usability... yes
checking nlopt.h presence... yes
checking for nlopt.h... yes
configure: Now testing for NLopt version 2.4.0 or greater.
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/PkgFlags.R
** libs
g++ -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c dummy.cpp -o dummy.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c nloptr.c -o nloptr.o
g++ -shared -L/usr/lib/R/lib -Wl,-z,relro -o nloptr.so dummy.o init_nloptr.o nloptr.o -L/usr/local/lib -lnlopt -L/usr/lib/R/lib -lR
installing to /home/stephen/R/x86_64-pc-linux-gnu-library/3.5/nloptr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/stephen/R/x86_64-pc-linux-gnu-library/3.5/nloptr/libs/nloptr.so':
libnlopt.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/stephen/R/x86_64-pc-linux-gnu-library/3.5/nloptr’
The downloaded source packages are in
‘/tmp/RtmpEtHKlT/downloaded_packages’
Warning message:
In install.packages("nloptr") :
installation of package ‘nloptr’ had non-zero exit status
I went into the nloptr folder and ran ./configure and the compile statements that I see in the output and I have nloptr.so in the src folder. Is there a way to continue the install manually and copy what needs to be copied? or can I check that .so if it works?
$ ldd nloptr.so
linux-vdso.so.1 (0x00007ffdb6dc1000)
libnlopt.so.0 => not found
libR.so => /lib/libR.so (0x00007f0e9e6b4000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0e9e530000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0e9e3ad000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0e9e393000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0e9e1d2000)
libblas.so.3 => /lib/x86_64-linux-gnu/libblas.so.3 (0x00007f0e9e163000)
libgfortran.so.5 => /lib/x86_64-linux-gnu/libgfortran.so.5 (0x00007f0e9def5000)
libquadmath.so.0 => /lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f0e9deb3000)
libreadline.so.7 => /lib/x86_64-linux-gnu/libreadline.so.7 (0x00007f0e9dc66000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f0e9dbf2000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f0e9dbca000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f0e9dbb5000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0e9d997000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0e9d98d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0e9d988000)
libicuuc.so.63 => /lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007f0e9d7b9000)
libicui18n.so.63 => /lib/x86_64-linux-gnu/libicui18n.so.63 (0x00007f0e9d4de000)
libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f0e9d4ab000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0e9d48a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0e9eb5b000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f0e9d45c000)
libicudata.so.63 => /lib/x86_64-linux-gnu/libicudata.so.63 (0x00007f0e9ba6c000)
$ ls /usr/local/lib/libnl*
/usr/local/lib/libnlopt.so /usr/local/lib/libnlopt.so.0 /usr/local/lib/libnlopt.so.0.10.0
Cheers
Stephen
2
Answers
As discussed in comments above the issue here was a ‘unconventional’ (and hence not-working) ‘installation’ of the nlopt library: one cannot just untar it somewhere as the dynamic linker needs to know about it, update its cache etc.
So in short the recommended answer is to, where available as a suitable version, install the
-dev
package from the distro. Here the command isafter which
configure
in the R package sees, and also gets to use it as the corresponding shared library itself gets installed from thelibnlopt0
package. (And we answered a few times why the-dev
package is always needed for building as opposed to merely running via the shared library package).The previous solution did not worked on my machine (Ubuntu 18.04, R 4.2.0). In installed
nlopt
library from github usingThen
install.packages("nloptr")
worked with no issues