Skip to content

mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64') #313

@arcticfox1919

Description

@arcticfox1919

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.<anonymous closure> (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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions