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.
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 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 |
# File 'ext/oci8/oraconf.rb', line 1029 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 = " -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/ 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 '#{Config::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 |