tauri-apps / libappindicator-rs

Rust safe bindings for the libappindicator library
Apache License 2.0
44 stars 19 forks source link

Use libloading for dynamic loading #31

Open wusyong opened 2 years ago

wusyong commented 2 years ago

libloading can load the dylib during runtime. This could be our solution for https://github.com/tauri-apps/tauri/issues/3859

Beanow commented 2 years ago

@wusyong I've been using this approach https://github.com/Beanow/libappindicator-rs/commit/3290335710ea0ec34e9d34c1811c0e443a9dc1e4 To avoid the pkg-config dependency on flatpak (I believe it's considered a dev dependency, so it's only available in the SDK, not runtime). This essentially uses the native dlopen function to locate it, so I can add LD_LIBRARY_PATH=/app/lib in flatpak.

BSD General Commands Manual               PKGCONF(1)

NAME
     pkgconf — a system for configuring build dependency information

I've not tried to make this work for appimages, but since we inject an APPDIR env var, wouldn't we be able to do the same with LD_LIBRARY_PATH?

Any issues you see with this approach (besides the missing error handling of course xD)

wusyong commented 2 years ago

@Beanow Oh I didn't know dlopen can do that. Can you create a PR and I'll test tmr. If everything works, I'll just update new version.

Beanow commented 2 years ago

For reference I'm making a PR, though it would remove the existing APPDIR stuff. It's quite likely we can remove the need for APPDIR, but need to investigate it more.