我正在尝试在没有网络连接的CentOS Linux机器上安装R包nloptr,步骤如下:
install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
这条命令会在线寻找以下文件。
http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz
然而,由于机器没有网络连接,因此这种方法失败了。
我尝试了以下stackoverflow帖子中的建议: 在Ubuntu上本地安装nloptr时出现问题 我按照以下方式更改了configure和configure.ac文件中的URL:
NLOPT_URL="file:///home//ravi//${NLOPT_TGZ}"
然而,当我再次尝试安装该软件包时,出现了以下错误:
> 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包吗?
更新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
当我尝试在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
更新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
然而,当我尝试重新安装nloptr包时,仍然会出现相同的共享对象错误。
有人能指导我解决共享库错误吗?