【问题标题】:Installing nloptr on Linux - fatal error: nlopt.h: No such file or directory在 Linux 上安装 nloptr - 致命错误:nlopt.h:没有这样的文件或目录
【发布时间】:2016-11-14 22:29:35
【问题描述】:

在 Linux (Ubuntu 14.04.4 LTS) 上安装 nloptr 软件包的另一个呼声。我查看了很多问题,但没有找到解决方案。

我无法在 R(版本 3.3.1/Rstudio 版本 0.99.902)中安装 lme4 包,因为 nloptr 的安装具有非零退出状态。当我尝试

    install.package("nloptr") 

我得到以下信息:

Installing package into ‘/home/rd14/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'unknown' 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 grep that handles long lines and -e... /bin/grep
checking for egrep... /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... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Content type 'application/x-gzip' length 2361992 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

configure: Starting to install library to /tmp/Rtmp7A1ldT/R.INSTALL66fffc391ed/nloptr/nlopt-2.4.2
configure: Done installing library to /tmp/Rtmp7A1ldT/R.INSTALL66fffc391ed/nloptr/nlopt-2.4.2
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c dummy.cpp -o dummy.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG     -I/tmp/Rtmp7A1ldT/R.INSTALL66fffc391ed/nloptr/nlopt-2.4.2/include -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c nloptr.c -o nloptr.o
nloptr.c:42:19: fatal error: nlopt.h: No such file or directory
 #include "nlopt.h"
                   ^
compilation terminated.
make: *** [nloptr.o] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/rd14/R/x86_64-pc-linux-gnu-library/3.3/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp4Y3TXJ/downloaded_packages’

您的帮助将不胜感激! 谢谢。

【问题讨论】:

  • 你的系统是什么?
  • Ubuntu 14.04.4 LTS
  • 你能在 /tmp/Rtmp7A1ldT/R.INSTALL66fffc391ed/nloptr/nlopt-2.4.2/include 中找到任何东西,还是安装过程失败后临时文件被删除了?
  • 嗯。当 Jelmer 和我构建这个设置时,它就可以工作了。但对您来说最简单的解决方法可能是只安装系统 nlopt 库,nloptr 包将检测和使用该库。 sudo apt-get install libnlopt-dev 也是如此,然后再次尝试安装 nlopt
  • 顺便说一句,lme4 当然也同样适用——只需执行sudo apt-get install r-cran-lme4。如果您指向 Ubuntu 的 CRAN 存储库(或者可能是 Michael 的额外 PPA),您也应该获得当前版本。以防万一您发现从源代码构建太麻烦...

标签: r packages lme4 install.packages nlopt


【解决方案1】:

当 Jelmer 和我构建此设置时,它仅在我的 Ubuntu 机器上运行,并且继续这样做——通过下载和构建 nlopt,或通过系统库。

当您在 Ubuntu 上时,最简单的解决方法可能是安装系统 nlopt 库,nloptr 包将检测和使用该库。也一样

sudo apt-get install libnlopt-dev 

然后尝试再次安装 nlopt。

同样,您应该能够从 Michael Rutter 的相应 PPA 中获得 lme4r-cran-lme4,如 CRAN 的 README for Ubuntu 中所述。

【讨论】:

  • 我试图在 R 3.4.0 中安装 carets 包,但无法完成安装,因为 nloptr 给了我一个错误。在尝试了这个解决方案后,它奏效了!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
相关资源
最近更新 更多