Executing dart run ffigen
got the following error:
Unhandled exception:
Invalid argument(s): Failed to load dynamic library '/Users/bruce/homebrew/opt/llvm/lib/libclang.dylib': dlopen(/Users/bruce/homebrew/opt/llvm/lib/libclang.dylib, 0x0001): tried: '/Users/bruce/homebrew/opt/llvm/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Users/bruce/homebrew/Cellar/llvm/13.0.1_1/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
#0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43)
#1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12)
#2 initializeGlobals (package:ffigen/src/header_parser/data.dart:41:33)
#3 initParser (package:ffigen/src/header_parser/parser.dart:48:3)
#4 parse (package:ffigen/src/header_parser/parser.dart:22:3)
#5 main (package:ffigen/src/executables/ffigen.dart:54:19)
#6 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#7 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
I checked my Flutter environment:
❯ file /Users/bruce/dev_tools/flutter/bin/cache/dart-sdk/bin/dart
/Users/bruce/dev_tools/flutter/bin/cache/dart-sdk/bin/dart: Mach-O 64-bit executable x86_64
When I run brew install llvm
to install llvm, what I get is a library for arm64, which I think is causing the error:
❯ lipo -info /Users/bruce/homebrew/Cellar/llvm/13.0.1_1/lib/libclang.dylib
Non-fat file: /Users/bruce/homebrew/Cellar/llvm/13.0.1_1/lib/libclang.dylib is architecture: arm64
It seems that the Flutter SDK does not have a version for Apple Silicon, so how to solve this problem?
❯ flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.3 21E230 darwin-arm, locale
zh-Hans-CN)
• Flutter version 2.8.1 at /Users/bruce/dev_tools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 months ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
• Pub download mirror http://10.141.64.130:8080
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /Users/bruce/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
I tried installing the Dart SDK for the Arm platform, but it still didn't work, using the standalone Dart environment, I get the following error:
❯ /Users/bruce/dev_tools/dart/bin/dart run ffigen
The Flutter SDK is not available.
#0 BoundSdkSource.getDirectory (package:pub/src/source/sdk.dart:125:7)
#1 SystemCache.load (package:pub/src/system_cache.dart:113:52)
#2 Entrypoint._assertLockFileUpToDate (package:pub/src/entrypoint.dart:599:19)
#3 Entrypoint.assertUpToDate (package:pub/src/entrypoint.dart:525:7)
#4 getExecutableForCommand (package:pub/src/executable.dart:304:16)
#5 RunCommand.run (package:dartdev/src/commands/run.dart:232:32)
#6 CommandRunner.runCommand (package:args/command_runner.dart:209:27)
#7 DartdevRunner.runCommand (package:dartdev/dartdev.dart:232:30)
#8 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:119:25)
#9 new Future.sync (dart:async/future.dart:296:31)
#10 CommandRunner.run (package:args/command_runner.dart:119:14)
#11 runDartdev (package:dartdev/dartdev.dart:67:29)
#12 main (file:///opt/s/w/ir/cache/builder/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#13 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:293:32)
#14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
ffigen
cannot be executed using the standalone Dart environment. – ScoundrellyD:\source\ffixyz>dart run ffigen --config config.yaml
withD:\source\ffixyz>dart --version
=>Dart SDK version: 2.16.1 (stable)
– Dub