Class: OraConfIC
Overview
OraConf for Instant Client
Constant Summary
Constants included from MiniRegistry
MiniRegistry::ERROR_FILE_NOT_FOUND, MiniRegistry::ERROR_SUCCESS, MiniRegistry::HKEY_LOCAL_MACHINE, MiniRegistry::RegCloseKey, MiniRegistry::RegOpenKeyExA, MiniRegistry::RegQueryValueExA
Instance Attribute Summary
Attributes inherited from OraConf
#cc_is_gcc, #cflags, #libs, #version
Instance Method Summary collapse
-
#initialize(ic_dir) ⇒ OraConfIC
constructor
A new instance of OraConfIC.
Methods inherited from OraConf
Methods included from MiniRegistry
#get_local_registry, #get_reg_value
Constructor Details
#initialize(ic_dir) ⇒ OraConfIC
Returns a new instance of OraConfIC.
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'ext/oci8/oraconf.rb', line 844 def initialize(ic_dir) init if ic_dir =~ /^\/usr\/lib(?:64)?\/oracle\/(\d+\.\d+\.\d+\.\d+)\/client(64)?\/lib(?:64)?/ # rpm package # official x86 rpms: # library: /usr/lib/oracle/X.X.X.X/client/lib/ # include: /usr/include/oracle/X.X.X.X/client/ # # official x86_64 rpms: # library: /usr/lib/oracle/X.X.X.X/client64/lib/ # include: /usr/include/oracle/X.X.X.X/client64/ # # third-party x86_64 rpms(*1): # library: /usr/lib64/oracle/X.X.X.X/client/lib/ # or /usr/lib64/oracle/X.X.X.X/client/lib64/ # include: /usr/include/oracle/X.X.X.X/client/ # # *1 These had been used before Oracle released official x86_64 rpms. # lib_dir = ic_dir inc_dir = "/usr/include/oracle/#{$1}/client#{$2}" else # zip package lib_dir = ic_dir inc_dir = "#{ic_dir}/sdk/include" end if RUBY_PLATFORM =~ /mswin32|cygwin|mingw32|bccwin32/ # when Windows unless File.exist?("#{ic_dir}/sdk/lib/msvc/oci.lib") raise <<EOS Could not compile with Oracle instant client. #{ic_dir}/sdk/lib/msvc/oci.lib could not be found. EOS raise 'failed' end @cflags = " \"-I#{inc_dir}\"" @cflags += " -D_int64=\"long long\"" if RUBY_PLATFORM =~ /cygwin/ @libs = get_libs("#{ic_dir}/sdk") ld_path = nil else @cflags = " -I#{inc_dir}" # set ld_path and so_ext case RUBY_PLATFORM when /aix/ ld_path = 'LIBPATH' so_ext = 'a' when /hppa.*-hpux/ if @lp64 ld_path = 'LD_LIBRARY_PATH' else ld_path = 'SHLIB_PATH' end so_ext = 'sl' when /darwin/ ld_path = 'DYLD_LIBRARY_PATH' so_ext = 'dylib' else ld_path = 'LD_LIBRARY_PATH' so_ext = 'so' end # check Oracle client library. unless File.exist?("#{lib_dir}/libclntsh.#{so_ext}") files = Dir.glob("#{lib_dir}/libclntsh.#{so_ext}.*") if files.empty? raise <<EOS Could not compile with Oracle instant client. '#{lib_dir}/libclntsh.#{so_ext}' could not be found. Did you install instantclient-basic? EOS else file = File.basename(files.sort[-1]) raise <<EOS Could not compile with Oracle instant client. #{lib_dir}/libclntsh.#{so_ext} could not be found. You may need to make a symbolic link. cd #{lib_dir} ln -s #{file} libclntsh.#{so_ext} EOS end raise 'failed' end @libs = " -L#{lib_dir} -lclntsh " end unless File.exist?("#{inc_dir}/oci.h") raise <<EOS '#{inc_dir}/oci.h' does not exist. Install 'Instant Client SDK'. EOS end $CFLAGS += @cflags if try_link_oci() major = try_constant("OCI_MAJOR_VERSION", "oci.h") minor = try_constant("OCI_MINOR_VERSION", "oci.h") if major and minor @version = format('%d%d0', major, minor) else # 10.1.0 doesn't have OCI_MAJOR_VERSION and OCI_MINOR_VERSION in oci.h. @version = "1010" end return end if RUBY_PLATFORM =~ /darwin/ is_intelmac = ([1].pack('s') == "\001\000") arch_ppc_error = false arch_i386_error = false open('mkmf.log', 'r') do |f| while line = f.gets # universal-darwin8.0 (Mac OS X 10.4?) if line.include? 'cputype (18, architecture ppc) does not match cputype (7)' # try to link an i386 library but the instant client is ppc. arch_i386_error = true end if line.include? 'cputype (7, architecture i386) does not match cputype (18)' # try to link a ppc library but the instant client is i386. arch_ppc_error = true end if line.include? '/libclntsh.dylib load command 8 unknown cmd field' raise <<EOS Intel mac instant client is for Mac OS X 10.5. It doesn't work on Mac OS X 10.4 or before. You have three workarounds. 1. Compile ruby as ppc binary and use it with ppc instant client. 2. Use JRuby and JDBC 3. Use a third-party ODBC driver and ruby-odbc. EOS # ' end # universal-darwin9.0 (Mac OS X 10.5?) if line.include? 'Undefined symbols for architecture i386:' # try to link an i386 library but the instant client is ppc. arch_i386_error = true end if line.include? 'Undefined symbols for architecture ppc:' # try to link a ppc library but the instant client is i386. arch_ppc_error = true end if arch_i386_error if is_intelmac # intel mac and '-arch i386' error raise <<EOS Could not compile with Oracle instant client. Use intel mac instant client. EOS else # ppc mac and '-arch i386' error raise <<EOS Could not compile with Oracle instant client. You may need to set a environment variable: RC_ARCHS=ppc export RC_ARCHS If it does not fix the problem, delete all '-arch i386' in '#{Config::CONFIG['archdir']}/rbconfig.rb'. EOS end end if arch_ppc_error if is_intelmac # intel mac and '-arch ppc' error raise <<EOS Could not compile with Oracle instant client. You may need to set a environment variable: RC_ARCHS=i386 export RC_ARCHS If it does not fix the problem, delete all '-arch ppc' in '#{Config::CONFIG['archdir']}/rbconfig.rb'. EOS else # ppc mac and '-arch ppc' error raise <<EOS Could not compile with Oracle instant client. Use ppc instant client. EOS end end end end end unless ld_path.nil? raise <<EOS Could not compile with Oracle instant client. You may need to set a environment variable: #{ld_path}=#{lib_dir} export #{ld_path} EOS end raise 'failed' end |