Use ldconfig(8) to find installed libraries. --- src/base/os.lua.orig Thu Dec 1 19:57:50 2016 +++ src/base/os.lua Thu Dec 1 20:00:17 2016 @@ -55,42 +55,15 @@ end function os.findlib(libname) - local path, formats - - -- assemble a search path, depending on the platform - if os.is("windows") then - formats = { "%s.dll", "%s" } - path = os.getenv("PATH") - elseif os.is("haiku") then - formats = { "lib%s.so", "%s.so" } - path = os.getenv("LIBRARY_PATH") - else - if os.is("macosx") then - formats = { "lib%s.dylib", "%s.dylib" } - path = os.getenv("DYLD_LIBRARY_PATH") - else - formats = { "lib%s.so", "%s.so" } - path = os.getenv("LD_LIBRARY_PATH") or "" - - for _, v in ipairs(parse_ld_so_conf("/etc/ld.so.conf")) do - path = path .. ":" .. v - end + libname = libname:gsub("^lib", "") + local file = io.popen("ldconfig -r", "r") + for line in file:lines() do + _, last = line:find(":-l" .. libname .. ".%d+.%d+ => ") + if last then + return line:sub(last + 1) end - - table.insert(formats, "%s") - path = path or "" - if os.is64bit() then - path = path .. ":/lib64:/usr/lib64/:usr/local/lib64" - end - path = path .. ":/lib:/usr/lib:/usr/local/lib" end - - for _, fmt in ipairs(formats) do - local name = string.format(fmt, libname) - local result = os.pathsearch(name, path) - if result then return result end - end - end + end