Julia 朱莉娅:检查c库是否存在

Julia 朱莉娅:检查c库是否存在,julia,Julia,有没有办法检查系统是否可以找到c库 我试图在库调用中使用try-catch块来测试它是否存在,但这实际上会杀死程序 try ccall( (:func, "libfoo"), Bool, () ) catch println("This line is never called. Ever") end 相关错误为: ERROR: error compiling anonymous: could not load module libfoo: libfoo: cannot ope

有没有办法检查系统是否可以找到c库

我试图在库调用中使用try-catch块来测试它是否存在,但这实际上会杀死程序

try
    ccall( (:func, "libfoo"), Bool, () )
catch
    println("This line is never called. Ever")
end
相关错误为:

ERROR: error compiling anonymous: could not load module libfoo: libfoo: cannot open shared object file: No such file or directory

您可以使用
find_library
在跳跃之前查看:

julia> find_library(["libc"])
"libc"

julia> find_library(["libfoo"])
""
如果找不到,您将从中获取空字符串

julia> help(find_library)
INFO: Loading help data...
Base.find_library(names, locations)

   Searches for the first library in "names" in the paths in the
   "locations" list, "DL_LOAD_PATH", or system library paths (in
   that order) which can successfully be dlopen'd. On success, the
   return value will be one of the names (potentially prefixed by one
   of the paths in locations). This string can be assigned to a
   "global const" and used as the library name in future
   "ccall"'s. On failure, it returns the empty string.

该死。我应该能找到的。感谢您在Julia v0.5的
Base
中找不到
find_库
。我想它可能已经移动到了
Libdl.find_library