python使用libclang的环境搭建,找不到Libclang
我已经将C:\Program Files (x86)\LLVM\bin加入到环境变量里的path里了
在代码中也用
clang.cindex.Config.set_library_file('C:\Program Files
(x86)\LLVM\bin\libclang.dll')
指明了libclang.dll的位置
测试用的test.py整个文件是
import sys
import clang.cindex
def find_typerefs(node, typename):
""" Find all references to the type named 'typename'
"""
if node.kind.is_reference():
ref_node = clang.cindex.Cursor_ref(node)
if ref_node.spelling == typename:
print 'Found %s [line=%s, col=%s]' % (
typename, node.location.line, node.location.column)
# Recurse for children of this node
for c in node.get_children():
find_typerefs(c, typename)
clang.cindex.Config.set_library_file('C:\Program Files (x86)\LLVM\bin\libclang.dll