I'm trying the Python binding for clang. I installed LLVM and its python bindings using homebrew
on Mac OS X Maverics with command line
brew install llvm --with-clang --with-python --with-lld
The loading code is
import clang
import clang.cindex
clang.cindex.Config.set_library_path('/usr/local/Cellar/llvm/3.5.0/lib')
index = clang.cindex.Index.create()
But this throws an error:
clang.cindex.LibclangError: dlopen(/usr/local/Cellar/llvm/3.5.0/lib/libclang.dylib, 6): Library not loaded: @rpath/libLLVM-3.5.dylib Referenced from: /usr/local/Cellar/llvm/3.5.0/lib/libclang.dylib Reason: image not found. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().
But I don't understand why this error occurs. Doesn't @rpath
here refers to /usr/local/Cellar/llvm/3.5.0/lib
? But there is a file called libLLVM-3.5.dylib
under that directory. Why does this loading cause an error and how to fix it?
Elevating @synthesizerpatel's comment to an answer:
Add the following environment variable to your environment:
DYLD_LIBRARY_PATH=/usr/local/Cellar/llvm/3.5.0/lib/
The readme also mentions
You may need to alter
LD_LIBRARY_PATH
so that the Clang library can be found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With