【问题标题】:Get ROracle to run on ubuntu让 ROracle 在 ubuntu 上运行
【发布时间】:2018-01-29 14:19:04
【问题描述】:

我已经从 Oracle 下载了 ROracle 1.3-1.tar.gz 和 Oracle 即时客户端 12.2 基本和开发 rpm。

this post 中所述,我执行了这些命令:

export ORACLE_HOME=/usr/lib/oracle/12.2/client64
sudo mkdir $ORACLE_HOME/rdbms
sudo mkdir $ORACLE_HOME/rdbms/public
sudo cp /usr/include/oracle/12.2/client64/* $ORACLE_HOME/rdbms/public

我尝试使用

安装 ROracle
R CMD INSTALL --configure-args='--with-oci-lib=/usr/lib/oracle/12.2/client64/lib --with-oci-inc=/usr/include/oracle/12.2/client64'  ROracle_1.3-1.tar.gz

然后输出显示

* installing to library ‘/home/s9970/R/x86_64-pc-linux-gnu-library/3.4’
* installing *source* package ‘ROracle’ ...
** package ‘ROracle’ successfully unpacked and MD5 sums checked
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/oracle/12.2/client64     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rodbi.c -o rodbi.o
In file included from rodbi.c:182:0:
rodbi.c: In function ‘rodbiResBind’:
rodbi.h:43:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8 {aka long int}’ [-Wformat=]
 # define _(String) (String)
                    ^
rodbi.c:200:36: note: in expansion of macro ‘_’
 #define RODBI_ERR_BIND_VAL_TOOBIG  _("bind value is too big(%lld), exceeds 2GB")
                                    ^
rodbi.c:2432:26: note: in expansion of macro ‘RODBI_ERR_BIND_VAL_TOOBIG’
         sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
                          ^
rodbi.h:43:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8 {aka long int}’ [-Wformat=]
 # define _(String) (String)
                    ^
rodbi.c:200:36: note: in expansion of macro ‘_’
 #define RODBI_ERR_BIND_VAL_TOOBIG  _("bind value is too big(%lld), exceeds 2GB")
                                    ^
rodbi.c:2469:26: note: in expansion of macro ‘RODBI_ERR_BIND_VAL_TOOBIG’
         sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
                          ^
rodbi.c: In function ‘rodbiPlsqlResBind’:
rodbi.h:43:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8 {aka long int}’ [-Wformat=]
 # define _(String) (String)
                    ^
rodbi.c:200:36: note: in expansion of macro ‘_’
 #define RODBI_ERR_BIND_VAL_TOOBIG  _("bind value is too big(%lld), exceeds 2GB")
                                    ^
rodbi.c:2816:28: note: in expansion of macro ‘RODBI_ERR_BIND_VAL_TOOBIG’
           sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
                            ^
rodbi.h:43:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8 {aka long int}’ [-Wformat=]
 # define _(String) (String)
                    ^
rodbi.c:200:36: note: in expansion of macro ‘_’
 #define RODBI_ERR_BIND_VAL_TOOBIG  _("bind value is too big(%lld), exceeds 2GB")
                                    ^
rodbi.c:2861:28: note: in expansion of macro ‘RODBI_ERR_BIND_VAL_TOOBIG’
           sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
                            ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/oracle/12.2/client64     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rooci.c -o rooci.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o ROracle.so rodbi.o rooci.o -L/usr/lib/oracle/12.2/client64/lib -lclntsh -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -lclntsh
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'ROracle.so' failed
make: *** [ROracle.so] Error 1
ERROR: compilation failed for package ‘ROracle’
* removing ‘/home/s9970/R/x86_64-pc-linux-gnu-library/3.4/ROracle’

我尝试导出这些环境变量,然后运行不带参数的命令,但我得到了同样的错误。

export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH    
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export OCI_LIB=/usr/lib/oracle/12.2/client64/lib
export LD_LIBRARY_PATH_64=/usr/lib/oracle/11.2/client6/lib:$LD_LIBRARY_PATH_64
R CMD INSTALL ROracle_1.3-1.tar.gz

我还将LD_LIBRARY_PATH 写入conf 文件,如here 所述,通过

echo "/usr/lib/oracle/12.2/client64/lib" | sudo tee /etc/ld.so.conf.d/oracle.conf

当我尝试从 Rstudio 加载 ROracle 时,仍然出现以下错误:

> library(ROracle)
Loading required package: DBI
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/ROracle/libs/ROracle.so':
  libclntsh.so.11.1: cannot open shared object file: No such file or directory

我在 /usr/lib/oracle/12.2/client64/lib/ 处设置了从 libclntsh.so.12.1 到 libclntsh.so.11.1 的合成链接,但在我看来,RStudio 正在错误的位置寻找我的 R - 即 /usr/local/... 而不是 usr/...。 我该如何解决这个问题?

我也试过设置

export RSTUDIO_WHICH_R=/usr/bin/R

但它也没有帮助。

【问题讨论】:

    标签: r roracle


    【解决方案1】:

    根据 ROracle INSTALL 文档,您应该使用

    export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH
    

    注意缺少的$LD_LIBRARY_PATH

    安装后,您可能希望看到下面的加载包:

    1. ROracle not working in R studio
    2. failing to load ROracle: unable to load shared object ROracle.so: libclntsh.so.11.1 No such file or directory

    【讨论】:

    • 不幸的是,我仍然收到与上一个命令相同的错误消息。
    • 您可能没有管理员权限。您可能希望使用dyn.load('/usr/lib/oracle/12.2/client64/lib/libclntsh.so.12.1') 在 R 中显式加载它,即共享 obj 的路径。然后运行install.packages('ROracle')
    • 感谢您的帮助。我确实有管理员权限,但问题似乎出在其他地方。当我按照你说的做时,R 说“配置:错误:找不到 OCI 库”
    • 你能分享更多关于配置错误的细节吗?你能ls /usr/lib/oracle/12.2/client64/lib 和 /usr/lib/oracle/12.2/client64/lib 中的 libclntsh 文件吗?
    • 再次感谢您的帮助。我在上面的问题中添加了 lib 信息。不幸的是,错误并没有多说:* 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 ‘/home/[user]/R/x86_64-pc-linux-gnu-library/3.4/ROracle’
    【解决方案2】:

    安装 ROracle 真的很痛苦。我发现效果很好的不是在每个安装命令前面加上sudo,而是使用sudo su 切换到超级用户,然后以超级用户身份执行整个安装。我不是 Linux 专家,所以我不能告诉你为什么这是一种更稳定的方式。但它对我们有用。

    我们还添加了一个 bash 文件 oracle.sh/etc/profile.d/

    oracle.sh

    LD_LIBRARY_PATH="/usr/lib/oracle/12.1/client64/lib:${LD_LIBRARY_PATH}"
    export LD_LIBRARY_PATH
    

    【讨论】:

    • 谢谢,我试过了,但我还是遇到和以前一样的错误
    • 我们使用这个命令安装 ROracle R CMD INSTALL --configure-args='--with-oci-lib=/usr/lib/oracle/12.1/client64/lib --with-oci-inc=/usr/include/oracle/12.1/client64' ROracle_1.3-1.tar.gz
    • 我也是(见上文),只有 12.2 而不是 12.1。
    • 你安装了sqlplus客户端吗? ` oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm` 可能是 12.2
    • 现在我做到了,我还添加了 oracle.sh 文件,但没有任何区别:/
    【解决方案3】:
    sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-
    instantclient.conf" sudo ldconfig
    

    描述于

    https://github.com/oracle/node-oracledb/issues/453

    为我工作。

    我用过

    dyn.load('/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1')
    

    在 R 中检查。在执行上述命令之前,它返回错误。

    我想知道前面提到的oracle.confcheck here)和oracle-instantclient.conf之间有什么区别(如果有的话)

    【讨论】:

      【解决方案4】:

      这解决了我的问题:

      R CMD INSTALL --configure-args='--with-oci-lib=/usr/lib/oracle/19.3/client64/lib --with-oci-inc=/usr/include/oracle/19.3/client64' ../ROracle_1.3-1.tar.gz
      

      【讨论】:

      • 欢迎来到 StackOverflow!感谢您的贡献。为了增加您的解决方案的价值,请提供一些背景信息、您的解决方案为何以及如何运作。请花点时间查看help center,尤其是formatting 部分。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 2019-09-04
      • 1970-01-01
      • 2020-10-12
      • 1970-01-01
      • 2020-09-24
      • 2014-01-16
      相关资源
      最近更新 更多