I am trying to create some Rust bindings to IUP using dynamic linking.
This works fine for iup.{so,dll}.

However, it fails to work for iupim.{so,dll}.

I have a prototype in Python and that had the same problem. However, in Python I could solve the problem like this:

DLL_ROOT = (pathlib.Path(__file__).parent / 'iup').resolve()
# Windows & error checking code omitted
DLL_ROOT /= 'linux'
iup_dll = DLL_ROOT / 'libiup.so'
iup = ctypes.cdll.LoadLibrary(iup_dll) # Equivalent to Rust's libloading::Library::new()

The above works. But continuing, this fails:
im_dll = DLL_ROOT / 'libiupim.so'
im = ctypes.cdll.LoadLibrary(im_dll)

However, I can get IM to load by doing this instead:
im_dll = 'iupim' # only the bare name needed in this case
im = ctypes.CDLL(im_dll, handle=iup)

This works because the `handle` refers to the original loaded `iup` library.

Unfortunately, I don't know how to do the equivalent in Rust. (I've asked on the Rust forum.)

But I just wondered if other people had had problems with dynamic loading and if there was another way to do it? Or if anyone has an example in C or C++ or Rust that loads both IUP and IM?


_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to