-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native Linux build can not find shared library when using Cargo workspaces #2460
Comments
Hi! Thanks for opening your first issue here! 😄 |
Hi, maybe try to use https://cjycode.com/flutter_rust_bridge/guides/how-to/load-library and customize the path of the library |
Using this method I wrote this fix I am happy with. import 'dart:io' show Platform;
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart';
var config = ExternalLibraryLoaderConfig(
stem: 'my_flutter_bridge',
ioDirectory: !Platform.isLinux ? 'rust/target/release/' : '../target/release/',
webPrefix: 'pkg/',
);
await RustLib.init(externalLibrary: await loadExternalLibrary(config)); However, I would prefer a proper fix on the build system level. Or at least a mention in the docs for this problem. But the priority of these things is up to you. I am going to keep the issue open in case you do want to address this, otherwise it can be closed. |
That looks reasonable! The most complete solution may be checking where is cargo workspaces and find out the target directory. But since this may not be of top priority, I guess the second way - mentioning in doc - is great. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Describe the bug
When using cargo workspaces the built Linux application crashes on startup because it is unable to locate the
.so
built from the bridge Rust crate. I followed the Cargo workspace How-to.The Android build with workspaces and the Linux build without workspaces both work fine on my system.
Changing
ioDirectory: 'rust/target/release/',
toioDirectory: '../target/release/',
infrb_generated.dart
can fix the issue, but I don't want to modify the generated code.Steps to reproduce
mkdir workspace_test && cd workspace_test
echo [workspace]\nmembers = ["my_flutter_bridge"] > Cargo.toml
flutter_rust_bridge_codegen create my_flutter_project --rust-crate-dir ../my_flutter_bridge
How-tocargo build --release
cd my_flutter_project
flutter run
Logs
Expected behavior
No response
Generated binding code
No response
OS
NixOS
Version of
flutter_rust_bridge_codegen
2.7.0
Flutter info
Version of
clang++
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: