-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make sure FFI interface from C++ <-> Dart is using static libraries #34
Comments
@Super-Genius I did some searching on the repo and found that the "genius_api_ffi.dart" is not referenced anywhere. I've debugged the code and as far as I could test the debugger never landed on this source file:
Is this the code you were talking about? Do you have any pointers on that? |
In order to test anything I'm trying to compile wallet-core. It caused an error due to rust nightly usage, since some things got "broken" on latest nightly builds. I temporarily changed the "install-rust-dependencies" script to a fixed nightly release:
@Super-Genius Right now I'm having some issues on CMakeLists, since it's requesting the boost directory. I infer that I'm supposed to point to the build/Android (or Linux or iOS)/Release/boost, correct? Also, after some research I don't think wallet-core was ever linked to GeniusWallet. After I'm able to create the libraries from wallet-core I'm gonna try to embed them on a wrapper on the application (without an extra plugin). The current build.gradle compiles the "native.cpp" source and creates an "libnative.so", which then its linked by the dart:ffi abstraction layer. My end goal is to replace this "native.cpp" test for a "TrustWalletWrapper.cpp" which will have basically "extern "C" and static or singletons for the wallet-core static libraries I'll link once I have them compiled. What do you think? |
Yes boost library linking should follow SuperGenius CMakeLists.txt default location for thirdparty and Find_Package() locating boost automatically. CMakeLists.Txt has a function that looks for a define for THIRDPARTY_DIR and if not defined sets to ../../thirdparty relative directory and that is used to define directories for header files and library builds with the target OS defines The WalletCore and GeniusSDK were never built and linked in using plugins. So, yes. This is the right direction for you to proceed |
I paused this task to compile the wallet-core on Android so I'd have something to test it. So far I've only changed CMakeLists and build.gradle to forward wallet-core library to flutter. I was able to load a function pointer (the wallet-core already exports C like symbols). I'll check if this approach is the best one, since it takes a lot of memory (had to increase emulator's heap to 2GB I think) and also I read that there's another way to link it statically with JNI |
There is no other easy ( less ram method ) for this FFI, you need heap
memory up to 3-4 GB for compilation. Because it needs to see all FFI
functions at once to build. Those are the side effect for dart / jni ( like
in java JNI )
…On Mon, Aug 21, 2023 at 5:30 PM Henrique A Klein ***@***.***> wrote:
I paused this task to compile the wallet-core on Android so I'd have
something to test it. So far I've only changed CMakeLists and build.gradle
to forward wallet-core library to flutter. I was able to load a function
pointer (the wallet-core already exports C like symbols). I'll check if
this approach is the best one, since it takes a lot of memory (had to
increase emulator's heap to 2GB I think) and also I read that there's
another way to link it statically with JNI
—
Reply to this email directly, view it on GitHub
<#34 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALLSR2T63XDOEFU2XDCHOTXWNWGXANCNFSM6AAAAAA2R2GBHQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Trust wallet core is being loaded as a static library, along with its dependencies (which aren't "whole-archived"). The procedure to insert extra libraries is pretty straightforward from now on, although for it to be added on all OSs one needs to change a couple of different places (cmakelists, runner xcode projects) |
The Original code assumed we were using dynamic/shared libraries/DLLs.
We are not, so the FFI code needs to be updated to use static libraries generated in ThirdParty.
https://docs.flutter.dev/platform-integration/ios/c-interop#dynamic-vs-static-linking
The text was updated successfully, but these errors were encountered: