简体   繁体   English

在 R 3.3.0 上安装 nloptr package 时出现问题

[英]Trouble installing nloptr package on R 3.3.0

I can't install the package nloptr 1.0.4 on R 3.3.0.我无法在 R 3.3.0 上安装 package nloptr 1.0.4。 The messages are the following:消息如下:

> install.packages("nloptr")
Installing package into ‘/Users/fgomesbarros/Library/R/3.3/library
(as ‘lib’ is unspecified)
trying URL 'https://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' 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... /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: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/bin/clang++ -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/opt/local/include    -fPIC  -pipe -Os -arch x86_64 -stdlib=libstdc++  -c dummy.cpp -o dummy.o
/usr/bin/clang -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/opt/local/include    -fPIC  -pipe -Os -arch x86_64  -c nloptr.c -o nloptr.o
/usr/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -L/opt/local/lib -Wl,-headerpad_max_install_names -o nloptr.so dummy.o nloptr.o -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/fgomesbarros/Library/R/3.3/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
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so':
  dlopen(/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
  Referenced from: /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
  Expected in: flat namespace
 in /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
* restoring previous ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/rz/dp6vmb39165406h9qv69q60c0000gn/T/RtmpLvLOmn/downloaded_packages’`

My R version is 3.3.0 as you can see below:我的 R 版本是 3.3.0,如下所示:

> version
               _                           
platform       x86_64-apple-darwin12.6.0   
arch           x86_64                      
os             darwin12.6.0                
system         x86_64, darwin12.6.0        
status                                     
major          3                           
minor          3.0                         
year           2016                        
month          05                          
day            03                          
svn rev        70573                       
language       R                           
version.string R version 3.3.0 (2016-05-03)
nickname       Supposedly Educational      

Any clues?有什么线索吗?

I also tried to install in olders versions (2.3.3 and 2.3.4) of R and had the same issue.我还尝试在 R 的旧版本(2.3.3 和 2.3.4)中安装并遇到同样的问题。

Thanks in advance.提前致谢。

I was able to solve the problem on my Mac using我能够使用我的 Mac 解决这个问题

$ brew install nlopt

Looking into the issue I noticed that others had reportedly resolved the issue on Ubuntu using调查这个问题,我注意到据报道其他人已经解决了 Ubuntu 上的问题,使用

$ sudo apt-get install libnlopt-dev

Apparently you now need to install it outside of R.显然你现在需要在 R 之外安装它。

对我来说,运行 CentOS 时,缺少的拼图是这样的:

     sudo yum install nlopt-devel

I tried to reinstall the package as a root and it worked!我尝试以 root 身份重新安装该软件包,并且成功了! I don't know why.我不知道为什么。

If you run into this problem with nloptr 1.2.0 and R 3.5.1 on macOS High Sierra, brew install nlopt will fail because of inadequate permissions in /usr/local .如果您在 macOS High Sierra 上使用 nloptr 1.2.0 和 R 3.5.1 遇到此问题,则brew install nlopt将由于/usr/local权限不足而失败。 The fix:修复:

$ mkdir /usr/local/Frameworks
$ sudo chown -R $(whoami) /usr/local/Frameworks
$ brew install nlopt

In other words, you don't want to change permissions for the entire /usr/local directory.换句话说,您不想更改整个/usr/local目录的权限。 The installation fails when the Homebrew tries to create /usr/local/Framework .当 Homebrew 尝试创建/usr/local/Framework时,安装失败。 So, do it by hand as shown above.所以,如上图所示,手动完成。 Then try again > install.packages("nloptr") .然后再试一次> install.packages("nloptr") It worked for me.它对我有用。

I had to reinstall R, using the R-CRAN installer and uninstalling the macports package.我不得不重新安装 R,使用 R-CRAN 安装程序并卸载 macports 包。

It finally worked!它终于奏效了!

In my case it was the issue of cmake as i am using ubuntu 22. i was installing matlib package of R and then in dependencies i faced this issue which is solved using In my case it was the issue of cmake as i am using ubuntu 22. i was installing matlib package of R and then in dependencies i faced this issue which is solved using

sudo apt-get install cmake sudo apt-get install cmake

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM