final dylib = ffi.DynamicLibrary.open('primitives.dylib');
"Invalid argument(s): Failed to load dynamic library (dlopen(primitives.dylib, 1): image not found)"
d: warning: ignoring file /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib
Also including the files is XCode result in a platform mismatch.d: warning: ignoring file /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib
--
You received this message because you are subscribed to the Google Groups "Dart FFI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/d806c536-fdcc-4712-8792-a27459f0f6ce%40googlegroups.com.
primitives: primitives.o
gcc -o a.out primitives.o
primitives.o: primitives.c
gcc -c primitives.c
dylib: primitives.o
gcc -dynamiclib -undefined suppress -flat_namespace primitives.o -o ../primitives.dylib
clean:
rm a.out primitives.o ../primitives.dylibHey Craig,You should use the dylib that is compiled for arm64 instead of intel64.See https://github.com/flutter/flutter/wiki/Binding-to-native-code-via-FFI for more information on how to bind to native code in iOS.Kind regards,
On Thu, Sep 12, 2019 at 7:10 AM Craig Jarman <craig....@gmail.com> wrote:
--Also including the files is XCode result in a platform mismatch.d: warning: ignoring file /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /Users/xxx/flutterApps/ffitest/ios/Runner/primitives.dylib
You received this message because you are subscribed to the Google Groups "Dart FFI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/d806c536-fdcc-4712-8792-a27459f0f6ce%40googlegroups.com.
--Daco Harkes
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/5dee3277-cd31-43e2-a5f8-9502448d4a93%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/CAHFkKc8Z%3DiNHHZoEwtOMA1eiKj5eLow3ixLc8ejtgnBcvdkXaA%40mail.gmail.com.
Are you trying to create a Flutter plugin? If so, it would be easier to create a Cocoa Pod, which will handle compiling a "fat" library (containing all architectures) and linking it correctly.The wiki page (https://github.com/flutter/flutter/wiki/Binding-to-native-code-via-FFI) does not recommend using a Makefile on OSX.
On Thu, Sep 12, 2019 at 11:24 AM 'Daco Harkes' via Dart FFI <dart...@googlegroups.com> wrote:
Hey Craig,You need to use a cross-compiler from intel to arm.You can see an example here https://github.com/dart-lang/sdk/blob/master/benchmarks/FfiCall/dart/native/MakefileKind regards,
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/5dee3277-cd31-43e2-a5f8-9502448d4a93%40googlegroups.com.
----Daco Harkes
You received this message because you are subscribed to the Google Groups "Dart FFI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/CAHFkKc8Z%3DiNHHZoEwtOMA1eiKj5eLow3ixLc8ejtgnBcvdkXaA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/4e0b8a8d-3419-4e20-ae82-2a6e8a2f2746%40googlegroups.com.
Can you just include your sources in the Xcode app directly then?
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/4e0b8a8d-3419-4e20-ae82-2a6e8a2f2746%40googlegroups.com.
primitives: primitives.o
gcc -o a.out primitives.o
primitives.o: primitives.c
gcc -c primitives.c
dylib: primitives.o
gcc -dynamiclib -undefined suppress -flat_namespace primitives.o -o ../primitives.dylib
clean:
rm a.out primitives.o ../primitives.dylibCC=gcc
CCARM=arm-linux-gnueabihf-gcc
CCARM64=aarch64-linux-gnu-gcc
CFLAGS=-Wall -g -O -fPIC
# Bump this whenever the benchmark is updated.
VERSION=1
.PHONY: all clean
all: out/linux/x64/libnative_functions.so out/linux/ia32/libnative_functions.so out/linux/arm64/libnative_functions.so out/linux/arm/libnative_functions.so
cipd:
cipd create -name dart/benchmarks/fficall -in out -install-mode copy -tag version:$(VERSION)
clean:
rm -rf *.o *.so out
out/linux/arm64:
mkdir -p out/linux/arm64
out/linux/arm64/native_functions.o: native_functions.c | out/linux/arm64
$(CCARM64) $(CFLAGS) -c -o $@ native_functions.c
out/linux/arm64/libnative_functions.so: out/linux/arm64/native_functions.o
$(CCARM64) $(CFLAGS) -s -shared -o $@ out/linux/arm64/native_functions.o--
You received this message because you are subscribed to the Google Groups "Dart FFI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/e8ab1900-8362-4af2-9909-9ae8babf82d8%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/CAKjqF1OFAfxV8pr3q00mDDg1LtVVvnavRpStp0JWwwfaye66wA%40mail.gmail.com.
Can you just include your sources in the Xcode app directly then?
It's not sufficient to create just the dylib on Mac. You need to create a `.framework`, which includes a code signature. This can be created via a separate Xcode project, and then you can follow the Wiki instructions to include that library.
However, a much simpler solution is to drop your sources into your app so they're loaded automatically and then use `DynamicLibrary.process` to access them.
Packaging native code with a Dart library is only streamlined for Flutter plugins on Android, Mac and iOS.
You should create your Dart library via `flutter create --template=plugin`.
This will create both an Xcode project and an Android Studio project inside your package where you can add the sources.
DynamicLibrary.open can be used to load a given API through providing the name. For example DynamicLibrary.open("libGLES_v3.so")Packaging native code with a Dart library is only streamlined for Flutter plugins on Android, Mac and iOS.You should create your Dart library via `flutter create --template=plugin`.This will create both an Xcode project and an Android Studio project inside your package where you can add the sources.We don't have an example yet, but we'd be happy to make your plugin the example :)Do you have a GitHub repo we can look at to help you better?
Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to dart...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/a8264e22-5a8d-429a-8085-04ca369d539d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/4D13D30A-94F5-47B6-9E99-0F9FD9E344D3%40gmail.com.
So with adding the libraries directly. Is there a need to compile the C code, to create the file?
A makefile is not required for consuming c-code from swift, but dart is different perhaps.
And, if so, do they need to be added to the flutter code, or included in the IOS and Android directory? Also, do these C libraries need to be complied for Arm64?
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/CD2B0817-4EB5-49BE-A108-484DA9D39FAC%40gmail.com.
| final dylib = ffi.DynamicLibrary.open('primitives.dylib'); |
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/CAKjqF1Mf4xNp%2BLHu1%3DSdEg8K6%3D%3Dc7_1%2BYgZSN8OmnK_DUmn3SA%40mail.gmail.com.
I think that creating a plugin is the cleanest approach, but it's not strictly necessary.We have made demos on Android and iOS by just adding the libraries directly, as on the Wiki page.But I know the wiki page is unclear.
On Fri, Sep 13, 2019 at 9:53 AM Craig Jarman <craig....@gmail.com> wrote:
Yes, an example would help. Plus a set of steps.
Is it correct one needs to create a plugin?
It's clear we need to improve the documentation and add an example.We also need to get rid of the outdated documentation from the SQLite prototype.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/a8264e22-5a8d-429a-8085-04ca369d539d%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Dart FFI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/4D13D30A-94F5-47B6-9E99-0F9FD9E344D3%40gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/5689105c-c442-46cb-8937-5783f46680df%40googlegroups.com.
Hi Craig,I did have a plugin in mind. Using the plugin infrastructure is important to ensure that the included C code is compiled with the right toolchain for the target platform (e.g. Xcode or NDK).However, I imagine a layout like this:
- android/ -> contains C
- ios/ -> contains C
- Dart -> C directly
The method-channels aspect of the plugin would not be used. We'll have an example to illustrate this soon.Could you please elaborate on your use case in particular?Thanks,Samir
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/5689105c-c442-46cb-8937-5783f46680df%40googlegroups.com.
Hey Renan
That would be similar.
As Samir has explained however, there is still a need for two compilation cycles and hence the plugin approach is recommend (one each for iOS and Android).
With plugin however there is typically some Java or Swift wrapper. I’m curious to know FFI removes the need for this, as XCode for one, won’t compile Dart code.
So that leave only the C-Lib in the package. I’m just guessing however.
To unsubscribe from this group and stop receiving emails from it, send an email to
dart-ffi+u...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dart-ffi/f1ceceba-e8ab-4ac8-ae4e-bac21aa0501e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dart-ffi/HK0PR06MB2642A9B611BA398E995692CCF98E0%40HK0PR06MB2642.apcprd06.prod.outlook.com.