(Note that the equivalent of a ccall in C is to use dlopen to dynamically
open the library path... that should generally lead to the same library
being used.)
On Unix systems, you can use the dladdr call. e.g. define
type DL_Info
fname::ByteString
fbase::Ptr{Void}
sname::ByteString
saddr::Ptr{Void}
end
function dladdr(p::Ptr)
info = Array(Ptr{Void}, 4)
err = ccall(:dladdr, Cint, (Ptr{Void}, Ptr{Ptr{Void}}), p, info)
err == 0 && error("unknown address $p")
return DL_Info(bytestring(convert(Ptr{Uint8}, info[1])), info[2],
bytestring(convert(Ptr{Uint8}, info[3])), info[4])
end
and then you can do e.g.
julia> dladdr(cglobal(:sin))
DL_Info("/usr/lib/system/libsystem_m.dylib",Ptr{Void}
@0x00007fff97ba5000,"sin",Ptr{Void} @0x00007fff97baee59)
or use e.g. dladdr(cglobal((:sin,:libm))) to specify a particular library.