I was trying to convert my codebase from 0.6 to 1.x, but noticed that all pointers from Libdl within a module now appear nulled after compilation. With the following module:
module MyModule lib = Libdl.dlopen("/path/to/my/lib.so") function foo() println(lib) end end
typing the following into the REPL:
using MyModule MyModule.foo()
in v0.7 and beyond
What I’m trying to achieve in my module is to open a library once, call it’s very expensive initialization once and then define a jl-function that can be called many times. But since the handle opened outside the function is nulled inside the function since 0.7, I now seemingly have to dlopen and initialize inside the function, i.e. have the expensive initialization in every function call. How can I avoid this? (The printing of the handle here is just a placeholder for any ccall I might want to make on that handle)
Btw, I’ve noticed that if I define the module inside the REPL and not as a package I still get the old behavior. Not sure why that changes anything.