kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

cygwin compilation problem #167

Closed tomasjura closed 7 years ago

tomasjura commented 7 years ago

Hi I had a problem during compilation on cygwin32 @ Windows 7. The error during configuration was:

/usr/share/ruby/2.3.0/fiddle.rb:47:in `initialize': No such file or directory (LoadError)
        from /usr/share/ruby/2.3.0/fiddle.rb:47:in `new'
        from /usr/share/ruby/2.3.0/fiddle.rb:47:in `dlopen'
        from /usr/share/ruby/2.3.0/Win32API.rb:15:in `initialize'
        from /usr/local/share/gems/gems/ruby-oci8-2.2.3/ext/oci8/oraconf.rb:29:in `new'

It seems that Win32API has a problem opening library advapi32.dll, though it exists in C:\Windows\System32 and this directory is in the $PATH.

I modified the ext/oci8/oraconf.rb (patch attached) so that it uses the native ruby registry access. The native access (Win32::Registry) exists since ruby 1.8.7. Compilation now works fine, though I do not use the ORACLE_HOME from registry. But short test showed that new function enum_homes should work as expected. Test

#!/bin/ruby
require 'Win32/Registry'
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Oracle') do  |reg|
  reg.each_key(){ |h|
    puts h
    l=reg.open(h)
    oracle_home,oracle_home_name = nil,nil
    l.each_value { |name,type,data|
      oracle_home=data if name == 'ORACLE_HOME'
      oracle_home_name=data if name == 'ORACLE_HOME_NAME'
    }
    puts " HOME_NAME=#{oracle_home_name} HOME=#{oracle_home}"
  }
end

Test output:

JavaDeploy
 HOME_NAME= HOME=
KEY_OraClient11g_home1
 HOME_NAME=OraClient11g_home1 HOME=C:\app\oraHome11_AdmDev\product\11.2.0\client_1
ODP.NET
 HOME_NAME= HOME=

oraconf_cygwin.diff.txt

kubo commented 7 years ago

Thank you! I'll check it and merge it later.

kubo commented 7 years ago

@tomasjura Thank you! I reproduced the issue after I upgraded cygwin from 2.5.1 to 2.8.0. I didn't use your patch but it is a good suggestion for me!