I can load my library, but I cannot unload it with LibraryUnload. I do have a void WolframLibrary_uninitialize(WolframLibraryData libData) (which does nothing). I get the following error:
LibraryFunction::unloadlib: The library "/my/library.so" cannot be unloaded.
I am not loading any function after loading the library. The OS is Linux x86_64.
I don't seem to be able to unload not even the demo library:
LibraryLoad@"demo"
LibraryUnload@%
This gets me the same error.
EDIT:
As worked out by Szabolcs and halirutan, I need to load one function at least (LibraryFunctionLoad) to have the initialization function called, and so being able to call LibraryUnload successfully. Yet, my ultimate goal is to be able to reload a new build of the library: this seems impossible because calling LibraryUnload doesn't actually close the handle of the library, and further calls to LibraryFunctionLoad reuse it. I checked with lsof, and if I delete the library and try to reload it I get that the new file is ignored and instead a handle to the old file (tagged correctly as DEL in lsof) is kept.
dlclose()'d (I checked with lsof, the handle is still there), which is what I actually want to do, because in the process of developing the library I might want to recompile it, and I don't want to reboot the kernel every time. – Lorenzo Pistone Dec 08 '13 at 18:47