我正在尝试安装ROracle。由于ROracle需要Oracle OCI库,我从Oracle网站下载了这些文件:instantclient-basic-macos.x64-12.2.0.1.0,instantclient-sdk-macos.x64-12.2.0.1.0.zip。我将这些文件放在〜/ Library / Caches / Homebrew中,并使用自制软件安装它们。
brew install instantclient-basic
brew install instantclient-sdk
Oracle网站还提到需要设置一些环境变量,所以我把它放在我的.bashrc文件中:
export LD_LIBRARY_PATH=/usr/local/Cellar/instantclient-basiclite/12.2.0.1.0/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/usr/local/Cellar/instantclient-basiclite/12.2.0.1.0/lib:$DYLD_LIBRARY_PATH
export NLS_LANG=UTF8
但是试图在R中安装ROracle导致了这一点:
> install.packages("ROracle")
Installing package into ‘/usr/local/lib/R/3.4/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/ROracle_1.3-1.tar.gz'
Content type 'application/x-gzip' length 308252 bytes (301 KB)
==================================================
downloaded 301 KB
Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Los_Angeles'
* installing *source* package ‘ROracle’ ...
** package ‘ROracle’ successfully unpacked and MD5 sums checked
configure: error: OCI libraries not found
ERROR: configuration failed for package ‘ROracle’
* removing ‘/usr/local/lib/R/3.4/site-library/ROracle’
Warning in install.packages :
installation of package ‘ROracle’ had non-zero exit status
R说它无法找到OCI库。到目前为止,Oracle的文档已被证明在解决此问题时不存在或毫无价值,但我找到了comment on the internet that seemed promising。所以我将它写入我的.bashrc并运行它:
R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib --with-oci-inc=/usr/local/Cellar/instantclient-sdk/12.2.0.1.0/lib/sdk/include' ROracle_1.3-1.tar.gz
结果如下:
installing to /usr/local/lib/R/3.4/site-library/ROracle/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
****unable to load shared object '/usr/local/lib/R/3.4/site-
library/ROracle/libs/ROracle.so':
dlopen(/usr/local/lib/R/3.4/site-library/ROracle/libs/ROracle.so, 6): Symbol
not found: _ons_recvthread_clone_sb
Referenced from: /usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib/libons.dylib
Expected in: flat namespace
in /usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib/libons.dylib
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/3.4/site-library/ROracle’
所以libons.dylib有问题吗?我应该怎么处理这些信息?
答案 0 :(得分:1)
对macOS的Instant Client 12.2进行了修补。从http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html获取并将其解压缩,例如转换为~/instantclient_12_2
我可以使用以下命令在macOS上安装ROracle:
brew install R
更新库中的rpath(使用R的正确版本号):
install_name_tool -add_rpath ~/instantclient_12_2 /usr/local/Cellar/r/3.4.3/lib/R/bin/exec/R
运行'R'然后:
install.packages("DBI")
从https://cran.r-project.org/web/packages/ROracle/index.html下载ROracle_1.3-1.tar.gz并安装它:
R CMD INSTALL --configure-args='--with-oci-lib=/Users/cjones/instantclient_12_2 --with-oci-inc=/Users/cjones/instantclient_12_2/sdk/include' ROracle_1.3-1.tar.gz
答案 1 :(得分:1)
在Intall ROracle Package for Windows and Mac OS上可以找到没有-add_rpath
的解决方案
我使用Macports中的R,并且做到了:
cd /opt/local/Library/Frameworks/R.framework/Resources/lib
sudo ln -s ~/Applications/instantclient/libclntsh.dylib.12.1
sudo ln -s ~/Applications/instantclient/libclntshcore.dylib.12.1
sudo ln -s libclntsh.dylib.12.1 libclntsh.dylib
sudo ln -s libclntshcore.dylib.12.1 libclntshcore.dylib
我认为每次升级到R后,只有指向libclntsh.dylib.12.1' is needed. But it does not harm to create the others as well. This way you do not need to run
install_name_tool`的链接。
创建链接后,我可以使用R CMD INSTALL