我的主数据库是一个本地mysql数据库,但我想偶尔在我的应用程序代码中直接连接到Oracle数据库。
oracle数据库托管在另一台RHEL服务器上。
我尝试安装ruby-OCI8 gem失败了(错误:无法构建gem原生扩展。)
我想知道oracle数据库是否必须是本地的才能使用这个gem,或者是否有更好的方法来实现它。
gem install ruby-oci8
Building native extensions. This could take a while...
ERROR: Error installing ruby-oci8:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for load library path...
LD_LIBRARY_PATH...
checking /opt/instantclient... yes
/opt/instantclient/libclntsh.so.11.1 looks like an instant client.
checking for cc... *** 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/bin/ruby
--with-instant-client
--without-instant-client
./oraconf.rb:562:in `check_cc': RuntimeError (RuntimeError)
from ./oraconf.rb:549:in `init'
from ./oraconf.rb:1001:in `initialize'
from ./oraconf.rb:343:in `new'
from ./oraconf.rb:343:in `get'
from extconf.rb:18
ng
---------------------------------------------------
Error Message:
C compiler doesn't work correctly.
Backtrace:
./oraconf.rb:562:in `check_cc'
./oraconf.rb:549:in `init'
./oraconf.rb:1001:in `initialize'
./oraconf.rb:343:in `new'
./oraconf.rb:343:in `get'
extconf.rb:18
---------------------------------------------------
See:
* http://ruby-oci8.rubyforge.org/en/HowToInstall.html
* http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html
我检查了mkmf.log文件:
"gcc -o conftest -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fs tack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -fPIC conftest.c -L. -L/usr/lib64 -L. -rdynamic -Wl,-export-dynamic -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/bin/ld: skipping incompatible /usr/lib/libruby-static.a when searching for -lruby-static
/usr/bin/ld: cannot find -lruby-static
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int main() { return 0; }
8 /* end */
答案 0 :(得分:0)
查看此博客文章是否可以帮助您完成OCI gem install http://jessehu.wordpress.com/2008/07/03/ruby-oci8-gem-available-2/
答案 1 :(得分:0)
首先,您需要安装Oracle Instant Client - 选择相应的Linux 32位或64位二进制文件。为了安全起见,使用我在所有Ruby和Oracle项目中使用的旧版本10.2.0.4。安装Basic,SDK和SQL * Plus软件包。
然后在LD_LIBRARY_PATH环境变量中包含Oracle Instant Client安装目录,以便Oracle Instant Client动态库处于加载路径中。
然后尝试安装ruby-oci8 gem。
然后安装activerecord-oracle_enhanced-adapter gem以便能够从ActiveRecord访问Oracle数据库。
我已发布说明how to install ruby-oci8 on Mac OS X - 其中大部分也适用于Linux(Mac上的DYLD_LIBRARY_PATH对应于Linux上的LD_LIBRARY_PATH)。
另外我创建了Sprinkle recipe for automated Oracle client installation on Linux - 可能它不是开始这个的最佳方式,但是如果你想构建自动服务器安装脚本,那么你可以看看它。
答案 2 :(得分:0)
您可以安装ruby-oci8 gem,如下所示
LD_LIBRARY_PATH = / local / home / soundar / instantclient_11_2 gem install ruby-oci8
注意:LD_LIBRARY_PATH是由oracle即时客户端目录路径设置的环境变量