NLoptr无法在Mac上安装:无法加载共享对象 [英] NLoptr failed to install on Mac: unable to load shared object

查看:150
本文介绍了NLoptr无法在Mac上安装:无法加载共享对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Mac OS High Sierra上安装nloptr软件包,以便使用许多不错的软件包,例如lme4,并且我正在Anaconda内部使用RStudio,R 3.4.2.我还安装了NLopt(从NLopt网站下载,而不是开发版本.我还安装了Xcode命令行工具.但是我仍然无法安装nloptr,并获得此

I'm trying to install the package nloptr on Mac OS High Sierra in order to use many nice packages like lme4, and I'm using RStudio inside Anaconda, with R 3.4.2. I have also installed NLopt (downloaded from the NLopt website, not the development version. I have also installed Xcode command line tool. But I still can't install nloptr, and get this

Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so':
dlopen(/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
Referenced from: /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so
Expected in: flat namespace
in /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so

我已经在线搜索了做什么,并确实将NLopt的安装路径添加到了/etc/ldpaths 文件中的LD_LIBRARY_PATH中,但是仍然出现相同的错误.是的,我遇到的问题与中的问题有关R 3.3.0 ,但是我没有找到一个可行的解决方案,因为问这个问题的人自己解决了这个问题,而且我不知道他说以根安装"的意思.有人可以帮忙吗?

I already searched online for what to do, and did add the path where NLopt was installed to LD_LIBRARY_PATH in the /etc/ldpaths file, but I still get the same error. Yes, I have the same problem as in Trouble installing nloptr package on R 3.3.0, but I didn't find a solution that works there since the person who asked that question resolved it himself and I don't know what he meant when he said "installed as a root". Can anyone help?

此外,在使用CMake安装NLopt时,我得到了类似的信息,这发生在许多不同的功能上:

Also, I got something like this when installing NLopt with CMake, and this happened to many different functions:

In file included from f77api.c:103:
./f77funcs.h:57:14: warning: 'nlopt_minimize_constrained' is deprecated
  [-Wdeprecated-declarations]
 *info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm, 
         ^
./nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked
  deprecated here
 int maxeval, double maxtime) NLOPT_DEPRECATED;
                              ^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
#  define NLOPT_DEPRECATED __attribute__((deprecated))
                                      ^

这就是为什么不加载库的原因吗?

Would this be why the library isn't loaded?

顺便说一句,我已经安装了Rcpp并对其进行了更新.Rcpp在我的计算机上工作.

BTW, I have installed Rcpp and updated it. Rcpp works on my computer.

更新:我将默认的C和C ++编译器更改为从R项目下载的clang4.我再次尝试安装,但出现了另一个错误:

Update: I changed the default C and C++ compiler to clang4 downloaded from R project. I tried the installation again, and got a different error:

Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so':
dlopen(/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so, 6): Library not loaded: @rpath/libnlopt.0.dylib
Referenced from: /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so
Reason: image not found
Error: loading failed

我试图通过 Sys.geteng(DYLD_LIBRARY_PATH ="/usr/local/lib")告诉R库在哪里,但是没有用.根据我从安装中获得的消息,实际上看起来R确实知道共享库在哪里,但它无法加载.请帮忙!

I have tried to tell R where the library is by Sys.geteng(DYLD_LIBRARY_PATH = "/usr/local/lib"), but it didn't work. It actually appears that R does know where the shared library is, according to the messages I got from installation, but it just can't load it. Please help!

推荐答案

没关系,我重新安装了Anaconda,并安装了独立的R和RStudio(不在Anaconda中),并且这些软件包都已成功安装.在Anaconda中使用RStudio也许是个坏主意.

Never mind, I reinstalled Anaconda, and installed the standalone R and RStudio (not within Anaconda), and those packages all installed successfully. Maybe it's a bad idea to use the RStudio inside Anaconda.

对于遇到类似情况的用户:由于我最近处理了线性代数,因此我改用了Microsoft R Open(MRO).然后,当我尝试在MRO中安装nloptr时,出现了类似的错误消息,由于找不到映像,共享库无法加载.我重新安装了CRAN R 3.4.3,并在那里安装了nloptr.因此,我发现 .libPaths()在CRAN R 3.4.3中安装了nloptr的位置,将nloptr文件夹复制到MRO存放软件包的位置,并使用实用程序RSwitch将R的默认版本更改为MRO..然后,我将nloptr加载到MRO中,安装了依赖于它的软件包,并使用了这些软件包.他们工作得很好.我不知道导致错误的MRO出了什么问题,但这至少可以解决问题.

For those who run into similar scenarios: I switched to Microsoft R Open (MRO), since I'm dealing a lot with linear algebra recently. Then when I tried to install nloptr in MRO, I got a similar error message that shared library failed to load because image not found. I reinstalled the CRAN R 3.4.3 and nloptr installed totally fine there. So I found where nloptr was installed in CRAN R 3.4.3 by .libPaths(), copied the nloptr folder to where MRO stores packages, and used the utility RSwitch to change the default version of R to MRO. Then I loaded nloptr in MRO, installed packages that depend on it, and used those packages; they worked fine. I don't know what's wrong with MRO that caused the error, but at least this worked.

这篇关于NLoptr无法在Mac上安装:无法加载共享对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆