我试图在没有互联网连接的CentOS Linux机器上安装R包nloptr,如下所示:
install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
Run Code Online (Sandbox Code Playgroud)
此命令依次在线查找以下文件
http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz
Run Code Online (Sandbox Code Playgroud)
但是,由于没有与计算机的Internet连接,因此失败.
我尝试了以下stackoverflow帖子中的建议:
我更改了configure和configure.ac文件中的URL,如下所示:
NLOPT_URL="file:///home//ravi//${NLOPT_TGZ}"
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试再次安装包时出现以下错误:
> 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
Run Code Online (Sandbox Code Playgroud)
有人可以指导我如何在本地安装这个R包吗?
更新1
根据Dirk关于首先安装nlopt的建议,我按照以下页面中的说明进行操作:
http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
我按如下方式安装了nlopt:
./configure --enable-shared
make
make install
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
Run Code Online (Sandbox Code Playgroud)
当我尝试在R中重新安装nloptr时,它不再查找nlopt链接,但会引发以下错误:
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
Run Code Online (Sandbox Code Playgroud)
更新2
正如Dirk所建议的,我查看了ldconfig命令并使用了以下引用:
http://codeyarns.com/2014/01/14/how-to-add-library-directory-to-ldconfig-cache/
我编辑了/etc/ld.so.conf文件,添加了包含共享库的目录/ usr/local/lib并运行了ldconfig命令.这添加了相关的共享库,如下所示:
libnlopt.so.0 (libc6,x86-64) => /usr/local/lib/libnlopt.so.0
libnlopt.so (libc6,x86-64) => /usr/local/lib/libnlopt.so
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试重新安装nloptr包时,我仍然得到相同的共享对象错误.
有人可以指导我共享库错误吗?
Dir*_*tel 31
当你说[t]他的命令依次在线查找以下文件时,你只能得到一半的故事.与实际nloptr包的维护者Jelmer一起,我修改了包以执行以下操作:
所以你可以简单地安装nlopt via
sudo apt-get install libnlopt-dev
Run Code Online (Sandbox Code Playgroud)
(或sudo dpkg -i /media/....从USB驱动器等指向文件的等效物)然后重新安装nloptr包.它会起作用.在我的机器上:
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:~$
Run Code Online (Sandbox Code Playgroud)
请注意它是如何从已找到nlopt安装的实际R包中仅编译两个文件的.
ren*_*olo 13
我在红帽企业Linux服务器版本6.6(圣地亚哥)上没有直接上网的生产机器上遇到了同样的问题.上面提出的修正不起作用:在系统上安装nlopt库时,后续安装nloptr的尝试失败并出现"nlopt_set_maxtime"错误.我试图摆弄nlopt的编译选项,但无济于事.我甚至在具有Internet连接的Ubuntu机器上重现了这个问题:我卸载了nloptr,在系统上安装了nlopt,然后nloptr安装失败了.
最后我通过以下步骤解决了问题:
编辑"nloptr/configure",注释掉该行
$("$ {R_HOME}/bin/Rscript" - vanilla -e"download.file(url ='$ {NLOPT_URL}',destfile ='$ {NLOPT_TGZ}')")
并插入一个新行:
$("$ {R_HOME}/bin/Rscript"--vanilla -e"file.copy(from ='/ tmp/nlopt-2.4.2.tar.gz',to ='$ {NLOPT_TGZ}')")
使用"R CMD INSTALL nloptr"安装.
小智 13
我在Ubuntu上遇到了类似的问题.除了在Dirk回答时安装nlopt-dev ,我还必须安装pkg-config:
sudo apt-get install pkg-config
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
如果您使用的是CentOS(并且可以访问Internet,但无法访问nlopt服务器),则可以nlopt先使用
yum install nlopt nlopt-devel
Run Code Online (Sandbox Code Playgroud)
然后你可以nloptr正常安装.
| 归档时间: |
|
| 查看次数: |
16030 次 |
| 最近记录: |