mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
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)
dart-lang/ffigen#1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12)
dart-lang/ffigen#2 initializeGlobals (package:ffigen/src/header_parser/data.dart:41:33)
dart-lang/ffigen#3 initParser (package:ffigen/src/header_parser/parser.dart:48:3)
dart-lang/ffigen#4 parse (package:ffigen/src/header_parser/parser.dart:22:3)
dart-lang/ffigen#5 main (package:ffigen/src/executables/ffigen.dart:54:19)
dart-lang/ffigen#6 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:32)
dart-lang/ffigen#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?
Contributor guide
Assessment
This issue has not been assessed yet.