<p dir="auto">I've been trying to have two different versions of a library available, in order to check which one to use, but I can't find out how to make this work. I even tried to explicitly separate the handles to the two versions of the library, but then ccall always calls the one which was loaded first (i.e. it ignores the library name, and just uses the function name).</p>
<p dir="auto">Here's the example code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; const pkgd_dl = dlopen(&quot;/home/carlo/.julia/GLPK/deps/usr/lib/libglpk&quot;)
Ptr{Void} @0x0000000003455da0

julia&gt; const system_dl = dlopen(&quot;libglpk&quot;)
Ptr{Void} @0x000000000326d740

julia&gt; ccall(:add_library_mapping, Cint, (Ptr{Cchar}, Ptr{Void}), &quot;pkgd_libglpk&quot;, pkgd_dl)
0

julia&gt; ccall(:add_library_mapping, Cint, (Ptr{Cchar}, Ptr{Void}), &quot;system_libglpk&quot;, system_dl)
0

julia&gt; bytestring(ccall((&quot;glp_version&quot;, &quot;pkgd_libglpk&quot;), Ptr{Uint8}, ()))
&quot;4.48&quot;

julia&gt; bytestring(ccall((&quot;glp_version&quot;, &quot;system_libglpk&quot;), Ptr{Uint8}, ()))
Warning: Possible conflict in library symbol glp_version
&quot;4.48&quot;"><pre class="notranslate"><code class="notranslate">julia&gt; const pkgd_dl = dlopen("/home/carlo/.julia/GLPK/deps/usr/lib/libglpk")
Ptr{Void} @0x0000000003455da0

julia&gt; const system_dl = dlopen("libglpk")
Ptr{Void} @0x000000000326d740

julia&gt; ccall(:add_library_mapping, Cint, (Ptr{Cchar}, Ptr{Void}), "pkgd_libglpk", pkgd_dl)
0

julia&gt; ccall(:add_library_mapping, Cint, (Ptr{Cchar}, Ptr{Void}), "system_libglpk", system_dl)
0

julia&gt; bytestring(ccall(("glp_version", "pkgd_libglpk"), Ptr{Uint8}, ()))
"4.48"

julia&gt; bytestring(ccall(("glp_version", "system_libglpk"), Ptr{Uint8}, ()))
Warning: Possible conflict in library symbol glp_version
"4.48"
</code></pre></div>
<p dir="auto">The last line should read <code class="notranslate">"4.45"</code> (and indeed it does if I don't load the other version first).<br>
I checked that the <code class="notranslate">add_library_sym</code> in <code class="notranslate">src/ccall.cpp</code> does find the correct handles and returns different pointers in the two cases.</p>
<p dir="auto">Is it possible at all to have two different functions with the same name from different libraries? Or am I doing something wrong?</p>
<p dir="auto">Ref: <a href="https://discourse.julialang.org/t/strange-behavior-with-void/2480" rel="nofollow">https://discourse.julialang.org/t/strange-behavior-with-void/2480</a></p>
<p dir="auto">Would it be possible to special-case creating a set out of a large vector of Voids? This is admittedly a weird thing to ask, but it looks like it will be significant for some upcoming LightGraphs work. Right now, if I have a large vector of Voids, Julia knows not to allocate any memory for that vector, but once I try turning it into a Set, it appears that sizehint! is applied based on the number of elements, and this allocates a large amount of memory for a single-element Dict.</p>