Should `dlopen` not first search the libraries loaded already like `dllist` ones?

Hi All,

I am trying to search for libc so that I can pass the malloc function to a library.

julia> dlopen("libc")
ERROR: could not load library "libc"
/usr/lib/x86_64-linux-gnu/libc.so: invalid ELF header
Stacktrace:
 [1] #dlopen#3(::Bool, ::Function, ::String, ::UInt32) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Libdl/src/Libdl.jl:109
 [2] dlopen at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Libdl/src/Libdl.jl:109 [inlined] (repeats 2 times)
 [3] top-level scope at none:0

while dllist gives me a different libc is loaded.

julia> dllist()
28-element Array{AbstractString,1}:
 "linux-vdso.so.1"                                                                  
 "/home/sambit/julia-install/julia-1.1.0/bin/../lib/libjulia.so.1"                  
 "/lib/x86_64-linux-gnu/libdl.so.2"                                                 
 "/lib/x86_64-linux-gnu/librt.so.1"                                                 
 "/lib/x86_64-linux-gnu/libpthread.so.0"                                            
 "/lib/x86_64-linux-gnu/libc.so.6"         

Should /lib/x86_64-linux-gnu/libc.so.6 not be loaded by dlopen in the first place?

regards,

Sambit

Instead of “libc” you should use “libc.so.6” then it should work.

best regards

Michael

Will check that. But that may be a bit platform specific.

regards,

Sambit

julia> dlopen("libc.so.6")
Ptr{Nothing} @0x00007fbe7ec7b400

works. But I am not fully convinced if this is the right approach. Is the libc6 kind of standard on all Unix platforms Julia supports? In that case it’s fine.

regards,

Sambit

I would assume libc6 is kind of default. Libc 2-5 were released in 90s.

regards,

Sambit

On my laptop with Lubuntu 16.04 libc.so.6 is a link to libc-2.23.so.

best regards

Michael

@mwolff,

There is libc as POSIX standard library version and there glibc which is the GNU libc version. The libc-2.23.so is the glibc version. We cannot rely on that one much as that may vary from system to system.

glibc-2.x is all libc6.

sambit@ubutubu:/lib/x86_64-linux-gnu$ ls -l *libc*
-rwxr-xr-x 1 root root 2030544 Apr 17  2018 libc-2.27.so
...
lrwxrwxrwx 1 root root      12 Apr 17  2018 libc.so.6 -> libc-2.27.so

regards,

Sambit

As far as I know, a new version of libc only changes the link from libc.so.6 to the new version. Or you can create your own local link to the latest version.

best regards

Michael