在Linux上安装nloptr [英] Installing nloptr on Linux
问题描述
我试图在没有互联网连接的CentOS Linux机器上安装R软件包 nloptr ,如下所示:
I am trying to install the R package nloptr on a CentOS Linux machine that doesn't have internet connection as follows:
install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
此命令反过来在线查找以下文件
This command in turn looks for the following file online
http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz
但是,这失败了,因为没有互联网连接到机器。
However, this fails since there is no internet connection to the machine.
我尝试了以下stackoverflow帖子中的建议:
I tried the suggestion from the following stackoverflow post:
我按如下所示更改了configure和configure.ac文件中的URL:
I changed the URL in configure and configure.ac files as follows:
NLOPT_URL="file:///home//ravi//${NLOPT_TGZ}"
但是,当我尝试安装再次打包:
However, I get the following error when I try to install the package again:
> install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
* installing *source* package 'nloptr' ...
files 'configure', 'configure.ac' have the wrong MD5 checksums
ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
有人可以引导我如何在本地安装此R软件包?
Can someone guide me on how to install this R package locally?
更新1
基于来自Dirk的关于首先安装nlopt的建议,我遵循了下一页中给出的说明:
Based on the suggestion from Dirk on installing nlopt first, I followed the instructions given in the following page:
http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
我安装了nl选择如下:
I installed nlopt as follows :
./configure --enable-shared
make
make install
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
当我尝试重新在R中安装nloptr,它将不再查找nlopt链接,但会引发以下错误:
When I tried to re-install nloptr in R, it doesn't look for the nlopt link anymore but throws the following error:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/opt/vertica/R/library/nloptr/libs/nloptr.so':
/opt/vertica/R/library/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
更新2
根据Dirk的建议,我研究了ldconfig命令nd使用了以下引用:
As suggested by Dirk, I looked into the ldconfig command and used the following reference:
http://codeyarns.com/2014/01/14/how-to-add-library-directory-to-ldconfig-cache/
我编辑了/etc/ld.so.conf文件,添加了包含共享库的目录/ usr / local / lib并运行了ldconfig命令。这将添加相关的共享库,如下所示:
I edited the /etc/ld.so.conf file, added the directory /usr/local/lib which contains the shared library and ran the ldconfig command. This added the relevant shared library as shown below:
libnlopt.so.0 (libc6,x86-64) => /usr/local/lib/libnlopt.so.0
libnlopt.so (libc6,x86-64) => /usr/local/lib/libnlopt.so
但是,当我尝试重新安装nloptr软件包时,仍然会遇到相同的共享库错误。
However, when I tried reinstalling the nloptr package, I still get the same shared object error.
有人可以指导我共享库错误吗?
Could someone guide me on the shared library error?
推荐答案
当您说 [t]他的命令依次在网上查找以下文件时,您只会得到一半的故事。我与实际nloptr软件包的维护者Jelmer一起修改了该软件包,以执行以下操作:
When you say [t]his command in turn looks for the following file online you only get half the story. Together with Jelmer, the maintainer of the actual nloptr package, I modified the package to do the following:
- 寻找一个安装libnlopt库,并使用它
- 如果找不到,请使用旧的行为并下载库
所以您可以简单地通过以下方式安装nlopt
So you could simply install nlopt via
sudo apt-get install libnlopt-dev
(或等效的 sudo dpkg -i / media/...。$c $ c>指向
USB驱动器等文件中的文件),然后重新安装 nloptr
软件包。它将正常工作。在我的机器上:
(or the equivalent sudo dpkg -i /media/....
pointing to the file from a
USB drive etc pp) and then reinstall the nloptr
package. It will just work. On my machine:
edd@max:~$ install.r nloptr ## install.r is in littler
trying URL 'http://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
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 nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -Wno-unused -pedantic -c dummy.cpp -o dummy.o
gcc -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -pedantic -std=gnu99 -c nloptr.c -o nloptr.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o nloptr.o -lnlopt -lm -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (nloptr)
The downloaded source packages are in
‘/tmp/downloaded_packages’
edd@max:~$
请注意仅如何编译实际的R包中的两个文件找到了nlopt安装。
Note how it compiled only two files from the actual R packages having found the nlopt installation.
这篇关于在Linux上安装nloptr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!