我试图在Mac OS高级Sierra上安装软件包nloptr以便使用许多漂亮软件包,如lme4,并且我在Anaconda中使用RStudio,并使用R 3.4.2。我还安装NLopt(从NLopt网站上下载,而不是开发的版本。我还安装了Xcode中的命令行工具,但我仍然无法安装nloptr,并获得该NLoptr无法在Mac上安装:无法加载共享对象
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
我已经在网上搜索怎么办,并且在/etc/ldpaths
文件中添加了安装NLopt的路径到LD_LIBRARY_PATH,但是我仍然得到相同的错误。是的,我有和Trouble installing nloptr package on R 3.3.0一样的问题,但是我没有找到在那里工作的解决方案因为问这个问题的人自己解决了这个问题,我不知道他的意思是什么时候他说“安装为root”。任何人都可以帮忙吗?
另外,我有类似这样的东西n使用CMake安装NLopt,并且发生许多不同的功能:
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))
^
这是为什么图书馆没有加载?
顺便说一句,我已经安装了Rcpp并更新它。 Rcpp在我的电脑上运行。
更新:我将默认的C和C++编译器更改为从R项目下载的clang4。我再次尝试安装,并得到了不同的错误:
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
我试图告诉R其中图书馆是Sys.geteng(DYLD_LIBRARY_PATH = "/usr/local/lib")
,但没有奏效。实际上,根据我从安装得到的消息,R确实知道共享库的位置,但它无法加载它。请帮忙!