rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Compilation fails on MacOS M1

Open maelp opened this issue 1 year ago • 6 comments

I'm building a project integrating rust-bindgen and doing cargo build --target=aarch64-apple-darwin and still I get this error, where it tries to check for an x86 lib instead of the (existing) arm64 one

 Unable to find libclang: "the `libclang` shared library at /opt/homebrew/Cellar/llvm/19.1.7/lib/libclang.dylib could not be opened: dlopen(/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang.dylib, 0x0005): tried: '/Users/primet/.wasmedge/lib/libclang.dylib' (no such file), '/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang.dylib' (no such file), '/opt/homebrew/Cellar/llvm/19.1.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))"

maelp avatar Feb 07 '25 17:02 maelp

What do you mean by "still"? Is there another issue open?

ojeda avatar Feb 07 '25 17:02 ojeda

No I mean, that's the error I'm getting

seems to be because it's confused and trying to use x86_64 instead of amd64

maelp avatar Feb 07 '25 17:02 maelp

@maelp did you ever find a solution to this?

danielchasehooper avatar May 31 '25 17:05 danielchasehooper

Also getting this error on Mac M1

Brandsma avatar Sep 07 '25 17:09 Brandsma

Could you check cargo --version --verbose, and verify that the host is aarch64-apple-darwin? Sometimes, I've seen people use x86_64-apple-darwin host tooling on their Aarch64 machine.

madsmtm avatar Sep 07 '25 19:09 madsmtm

@madsmtm this was indeed the issue for me. Thanks!

After running cargo --version --verbose it seemed that I was indeed running the x86_64-apple-darwin host tooling.

Running the following installed the correct toolchain for me:

rustup default stable-aarch64-apple-darwin

Brandsma avatar Sep 11 '25 18:09 Brandsma