In the documentation, it says, in the string, you might omit the file extension (.so, .dylib) , dlopen appends it and loads the library but I cannot get it to work.
lib = Libdl.dlopen(joinpath(@__DIR__, "mylib"))
mylib
is actually mylib.so
In the documentation, it says, in the string, you might omit the file extension (.so, .dylib) , dlopen appends it and loads the library but I cannot get it to work.
lib = Libdl.dlopen(joinpath(@__DIR__, "mylib"))
mylib
is actually mylib.so
What operating system are you on? The suffix that gets automatically appended should be given by Libdl.dlext
.
I was using Linux through WSL on Windows but what I want to do is throw in shared libraries compiled in Mac OS and Linux into a shared folder so people can access it and use it on the platform they are using. I have the .dylib
and .so
files already compiled.
What I expect is when I execute lib = dlopen(joinpath(@__DIR__, "mylib"))
it should append the extension and get mylib.dylib
if one is on Mac and mylib.so
if one is on Linux?
I resolved this issue using lib = dlopen(joinpath(@__DIR__, "mylib.$(Libdl.dlext)"))
although I think it says in the documentation that dlopen should do this automatically.
Can you file an issue? I suspect that this is a problem with julia on WSL.
Internally, the appended extension is defined in C code and should be the same as Libdl.dlext
, but Iām guessing that on WSL it gets confused about what operating system is running and the two get out of sync.