我試圖在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確實知道共享庫的位置,但它無法加載它。請幫忙!