0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

`brew install llvm` a nightmare for arm64 CPUs

Posted at

The title says it all, just leaving a note for myself on how I got ffigen running on flutter/dart.
Without proper installation steps, the command dart run ffigen or flutter pub run ffigen WILL throw an error on the mac m1 processors.

Unhandled exception:
Invalid argument(s): Failed to load dynamic library '/Users/<user>/homebrew/opt/llvm/lib/libclang.dylib': dlopen(/Users/<user>/homebrew/opt/llvm/lib/libclang.dylib, 0x0001): tried: '/Users/<user>/homebrew/opt/llvm/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Users/<user>/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)

Or something similar will terminate the command or binding files from being generated correctly.

Now it's important to note how I got here, installing the dependecies is no big deal and shouldn't really differ regardless of CPU choice. However, it's the LLVM that really gets you.

Any traditional doc will most likely tell you to run the equivalence of the following command: brew install llvm. While this gets the job done in terms of installing a version of LLVM, it automatically installs for the arm64, and NOT the x86_64. The latter is what's needed to run ffigen.

Therefore, if you already have LLVM installed, 1. uninstall. And you need to specify the x86_64 version of LLVM like so 2. arch -x86_64 /usr/local/homebrew/bin/brew install llvm. Then finally, you need the same version of ffi. 3. sudo arch -x86_64 gem install ffi.

Restart VSCode and execute the command again flutter pub run ffigen.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?