1

我正在尝试安装 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 的文档已被证明在解决此问题方面不存在或毫无价值,但我在互联网上发现了一条看起来很有希望的评论。所以我把它写到我的 .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 有什么问题吗?我应该如何处理这些信息?

4

2 回答 2

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
于 2018-01-15T10:07:53.437 回答
1

可以在适用于 Windows 和 Mac OS 的 Intall ROracle 软件包中-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

我认为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每次升级到 R 后只有指向 install_name_tool的链接。

创建链接后,我能够使用安装 ROracleR CMD INSTALL

于 2018-08-27T14:33:17.043 回答