I am trying to execute clang 5.0 with the next commands but it does not work.. I typed:
import clang
import clang.cindex
clang.cindex.Config.set_library_file('/usr/lib/x86_64-linux-gnu/libclang-5.0.so.1')
id = clang.cindex.Index.create()
and I received the following error:
clang.cindex.LibclangError: /usr/lib/x86_64-linux-gnu/libclang-5.0.so.1: undefined symbol: clang_CXXRecord_isAbstract. Please ensure that your python bindings are compatible with your libclang.so version.
I am using clang-5.0 with the bindings from https://github.com/llvm-mirror/clang
Windows
I haven't tested this right now, but it worked a month ago for me.
Either download the src code from github and go to /bindings/python/ and copy the clang directory and paste it into your python site packages dir or (try both) pip install clang-5
Download the llvm binares. If you have python-32bit then install llvm 32bit!! Otherwise it wont work. For 64bit python install the 64bit binaries
import clang.cindex as cl
and in your code do cl.Config.set_library_file("your/path/to/libclang.dll")
libclang.dll should be in your clang/bin installation directoryLinux
Running it right now, so it works for me
pip3 install clang-5
from your package manager either get llvm-clang or llvm-clang-32bit depending on your python installation
In your python program just import clang.cindex as cl
and in your code do cl.Config.set_library_file("your/path/to/libclang.so")
From my experience libclang.so should be located in either /usr/lib32/ or usr/lib64/
Hope this helps!