flet-dev / flet-dev/flet

Linking to or packaging native libraries with a Flet app

Open
#4,091 1 comment 0 reactions 1 assignee View on GitHub

@FeodorFitsner is already working on this.

Since Oct 8, 2024.

Dominant language
Python
Stars
17k
Forks
694
Avg merge
1d 14h
Merged PRs (30d)
33

Description

Duplicate Check
Describe the requested feature

What is the recommended approach to linking a needed system library into my Flet app?

I depend on libsodium (through pysodium), a popular cryptography library, at /usr/local/lib/libsodium.23.dylib yet get the runtime code signing error

OSError: dlopen(/usr/local/lib/libsodium.dylib, 0x0006): tried: '/usr/local/lib/libsodium.dylib' (code signature in <0541E863-5412-3036-A49C-84E95E4A0C98> '/usr/local/lib/libsodium.23.dylib' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs)

This is after doing the codesigning and notarization to build my .dmg file for distribution.

I see the Flutter discussion of Flutter tools support for packaging/linking to native libraries and am wondering if I need to take some FFI approach or just include the libsodium.23.dylib as a part of my build and codesigning process, as in

  • download source,
  • compile for target architecture, and
  • sign the libsodium.23.dylib file along with signing the entire Flet app bundle.

This seems a bit heavyweight, though if that's what I must do, then that's what I will do.

A relevant issue from the Flutter repo is https://github.com/flutter/flutter/issues/33227 (Flutter tools support for packaging/linking to native libraries)

This flet issue is probably related: https://github.com/flet-dev/flet/issues/2823 (libmpv.so.1 not found (when libmpv is already installed) - fixable but hacky)

Suggest a solution

I suggest creating a strong recommendation in the Flet documentation to do static linking:
downloading and building dependent libraries for each target architecture and linking them to the built Flutter app during the build process.

Screenshots

No response

Additional details

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.