SOLVED: Bindgen + libclang issues on macOS

#1

I’m running into issues building a project that uses bindgen. I’m attempting to use clang 7.0. It was installed using MacPorts. Here’s the exact error message:

thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /opt/local/libexec/llvm-7.0/lib/libclang.dylib could not be opened: dlopen(/opt/local/libexec/llvm-7.0/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm13ErrorInfoBaseE\n  Referenced from: /opt/local/libexec/llvm-7.0/lib/libclang.dylib\n  Expected in: /Users/agaspar/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /opt/local/libexec/llvm-7.0/lib/libclang.dylib"', src/libcore/result.rs:997:5

EDIT: Here’s the “panic” message unquoted:

the `libclang` shared library at /opt/local/libexec/llvm-7.0/lib/libclang.dylib could not be opened: dlopen(/opt/local/libexec/llvm-7.0/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm13ErrorInfoBaseE
  Referenced from: /opt/local/libexec/llvm-7.0/lib/libclang.dylib
  Expected in: /Users/agaspar/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib
 in /opt/local/libexec/llvm-7.0/lib/libclang.dylib

What appears to be happening is that libclang, when loaded, is trying to use the libLLVM installed with my Rust toolchain, which is not compatible with libclang 7.0. I’ve tried using older version of libclang (5.0 and 6.0) to no avail.

Does anybody have any ideas on how to solve this problem?

0 Likes

#2

Nevermind, apparently I was on a super old bindgen. Seems to be working now.

0 Likes