在linux上安装ruby-oci8时,我得到了cannot compile OCI
错误,我使用的命令是gem install ruby-oci8 -v '2.2.7'
,我使用的是oracle全客户端
[root@advlints01 redf]# gem install 'ruby-oci8' -v '2.2.7'
Building native extensions. This could take a while...
ERROR: Error installing ruby-oci8:
ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8
/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby -I /usr/local/rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190916-29697-1loq660.rb extconf.rb
checking for load library path...
LD_LIBRARY_PATH...
checking /oracle/app/oracle/product/12.2.0/client_1/lib... skip: /oracle/app/oracle/product/12.2.0/client_1/lib/libclntsh.so.12.1 is for i386 cpu.
checking ld.so.conf... no
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for sys/types.h... yes
checking for ruby header... ok
Get the version of Oracle from SQL*Plus... 1220
try -I/oracle/app/oracle/product/12.2.0/client_1/rdbms/public
checking for oci.h... yes
checking for OCIEnvCreate() in oci.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-2.5.1/bin/$(RUBY_BASE_NAME)
--with-instant-client
--without-instant-client
/usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:755:in `initialize': RuntimeError (RuntimeError)
from /usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:269:in `new'
from /usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:269:in `get'
from extconf.rb:22:in `<main>'
---------------------------------------------------
Error Message:
cannot compile OCI
Backtrace:
/usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:755:in `initialize'
/usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:269:in `new'
/usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7/ext/oci8/oraconf.rb:269:in `get'
extconf.rb:22:in `<main>'
---------------------------------------------------
See:
* http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-full-client.md for Oracle full client
* http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client
* http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.md for OS X
* http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/report-installation-issue.md to report an issue.
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/extensions/x86_64-linux/2.5.0/ruby-oci8-2.2.7/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/gems/ruby-oci8-2.2.7 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.5.1@real_estate_fund/extensions/x86_64-linux/2.5.0/ruby-oci8-2.2.7/gem_make.out
[root@advlints01 redf]#
发布于 2020-02-02 12:58:34
看起来我找到问题的原因了。我正在运行arch linux (manjaro 18xfce),有一个特定于arch linux oracle的安装过程,使用makepkg
和pacman
,所以,oracle-xe包一切正常,安装后我可以运行sqlplus
并连接到xe
数据库,这是一个默认创建的数据库(通常),但我无法编译ruby-oci8gem(2.2.8v),经过一些研究,我发现问题是在$ORACLE_HOME/lib
文件夹中缺少链接:
libclntsh.so -> libclntsh.so.11.1
和libocci.so -> libocci.so.11.1
11.1是一个lib版本(它取决于oracle版本,例如:11.2、19.5等)
在oracle
用户下通过ln -s
创建这些链接之后,就可以编译ruby-oci8了。
注意:我使用的是完整的instant
客户端,而不是即时客户端,并且所有的指南都没有提到如何链接这些.so
文件,但是所有与oracle客户端相关的指南都说it =D,这是来自ruby-oci8
- instant client installation开发人员的指南
https://stackoverflow.com/questions/57958341
复制相似问题