Class: OraConfIC
Overview
OraConf for Instant Client
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
Constructor Details
#initialize(ic_dir) ⇒ OraConfIC
Returns a new instance of OraConfIC.
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 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
# File 'ext/oci8/oraconf.rb', line 935 def initialize(ic_dir) init if ic_dir =~ /^\/usr\/lib(?:64)?\/oracle\/(\d+(?:\.\d+)*)\/client(64)?\/lib(?:64)?/ # rpm package # x86 rpms after 11.1.0.7.0: # library: /usr/lib/oracle/X.X/client/lib/ # include: /usr/include/oracle/X.X/client/ # # x86_64 rpms after 11.1.0.7.0: # library: /usr/lib/oracle/X.X/client64/lib/ # include: /usr/include/oracle/X.X/client64/ # # x86 rpms before 11.1.0.6.0: # library: /usr/lib/oracle/X.X.X.X/client/lib/ # include: /usr/include/oracle/X.X.X.X/client/ # # x86_64 rpms before 11.1.0.6.0: # 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 = get_libs(lib_dir) 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" if RUBY_PLATFORM =~ /darwin/ and 1.size == 8 and `sw_vers -productVersion`.chomp == "10.7" $stderr.print <<EOS WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! 64-bit Oracle instant client doesn't work on OS X Lion. See: https://forums.oracle.com/forums/thread.jspa?threadID=2187558 The compilation is continued because the issue may be fixed in future. WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! EOS end end return end if RUBY_PLATFORM =~ /darwin/ open('mkmf.log', 'r') do |f| while line = f.gets 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 case line when /cputype \(\d+, architecture \w+\) does not match cputype \(\d+\) for specified -arch flag: (\w+)/ missing_arch = $1 when /Undefined symbols for architecture (\w+)/ missing_arch = $1 when /missing required architecture (\w+) in file/ missing_arch = $1 end if missing_arch if [nil].pack('p').size == 8 my_arch = 'x86_64' elsif "\x01\x02".unpack('s')[0] == 0x0201 my_arch = 'i386' else my_arch = 'ppc' end raise <<EOS Could not compile with Oracle instant client. You may need to set the environment variable RC_ARCHS or ARCHFLAGS as follows: RC_ARCHS=#{my_arch} export RC_ARCHS or ARCHFLAGS='-arch #{my_arch}' export RC_ARCHS If it does not fix the problem, delete all '-arch #{missing_arch}' in '#{RbConfig::CONFIG['archdir']}/rbconfig.rb'. EOS 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 |