我有一个带有antiX的盒子,它是Debian的克隆。我编译并安装了nlopt,但仍然:
> 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
我进入nloptr文件夹并运行./配置和我在输出中看到的编译语句,并且在src文件夹中有nloptr.so。是否有办法继续手动安装并复制需要复制的内容?或者我可以检查一下.so是否有效?
$ 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
干杯
斯蒂芬
发布于 2021-08-02 02:04:04
正如在上面的评论中所讨论的,这里的问题是nlopt库的“非常规”(因此不起作用)“安装”:我们不能仅仅在某个地方解压它,因为动态链接器需要了解它,更新它的缓存等等。
因此,简单地说,推荐的答案是,如果可以作为合适的版本,从发行版中安装-dev
包。这里的命令是
sudo apt install libnlopt-dev
之后,R包中的configure
将看到,并将其作为相应的共享库本身从libnlopt0
包中安装。(我们回答了几次为什么构建总是需要-dev
包,而不是仅仅通过共享库包运行)。
发布于 2022-05-25 19:45:51
以前的解决方案在我的机器上没有工作(Ubuntu18.04,R4.2.0)。在已安装的nlopt
库中,使用
git clone https://github.com/stevengj/nlopt.git
cd nlopt
mkdir build
cd build
cmake ..
make
sudo make install
然后install.packages("nloptr")
就没有问题了
https://stackoverflow.com/questions/68614337
复制相似问题