Skip to content

Commit 17066dc

Browse files
committed
Fix an infinite loop while searching for libmysqlclient when mysql_config is not found
Generally improve the code for trying the extra runtime libraries
1 parent cb3e98d commit 17066dc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ext/mysql2/extconf.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,22 @@ def asplode lib
7373
rpath_dir = libs
7474
else
7575
inc, lib = dir_config('mysql', '/usr/local')
76-
libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
77-
found = false
78-
while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
79-
exit 1 if libs.empty?
80-
found ||= have_library(libs.shift)
76+
unless find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
77+
found = false
78+
# For some systems and some versions of libmysqlclient, there were extra
79+
# libraries needed to link. Try each typical extra library, add it to the
80+
# global compile flags, and see if that allows us to link libmysqlclient.
81+
warn "-----\nlibmysqlclient is missing. Trying again with extra runtime libraries...\n-----"
82+
83+
%w{ m z socket nsl mygcc }.each do |extra_lib|
84+
if have_library(extra_lib) && find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
85+
found = true
86+
break
87+
end
88+
end
89+
asplode('libmysqlclient') unless found
8190
end
8291

83-
asplode("mysql client") unless found
84-
8592
rpath_dir = lib
8693
end
8794

0 commit comments

Comments
 (0)