I'm playing around with calling c code. After changes in my code and thus
in the shared library I need to restart Julia in order to make the new code
available in Julia/ccall.
Question: is it possible to unload (and reload) a library? (It works using
dlopen/dlclose without a ccall. But as soon as I call ccall it doesn't work
anymore and the library stays loaded, I read something on a Mac forum about
executing two times dlclose (but then Julia crashes)). Happens on a Mac,
Julia 0.4.3. Thank you.
Code:
### load/unload dynamic library works in principle...
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 0
hellohdl = Libdl.dlopen("/Users/chappi/_curr/c_und_julia/hello")
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 1
Libdl.dlclose(hellohdl)
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 0
### ...but after a ccall I cannot unload 'hello' library
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 0
hellohdl = Libdl.dlopen("/Users/chappi/_curr/c_und_julia/hello")
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 1
ccall( (:my_main, "hello"), Cint, ())
#=ccall( :my_main, Cint, ())=# # no difference
Libdl.dlclose(hellohdl)
@assert length(filter(x->contains(x, "hello"), Libdl.dllist())) == 0 #
ERROR