'python can't load clang library under cygwin environment

I installed the latest cygwin64 under windows 10, then started to install some cygwin packages like python3.9 and clang 8.0.1, then via cygwin terminal, pip3 install clang==8.0.1 Now, I'm trying the following:

$ python3 
Python 3.9.10 (main, Jan 20 2022, 21:37:52) 
[GCC 11.2.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import clang.cindex
>>> index = clang.cindex.Index.create()
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/clang/cindex.py", line 4172, in get_cindex_library
    library = cdll.LoadLibrary(self.get_filename())
  File "/usr/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/clang/cindex.py", line 2698, in create
    return Index(conf.lib.clang_createIndex(excludeDecls, 0))
  File "/usr/local/lib/python3.9/site-packages/clang/cindex.py", line 212, in __get__
    value = self.wrapped(instance)
  File "/usr/local/lib/python3.9/site-packages/clang/cindex.py", line 4146, in lib
    lib = self.get_cindex_library()
  File "/usr/local/lib/python3.9/site-packages/clang/cindex.py", line 4177, in get_cindex_library
    raise LibclangError(msg)
clang.cindex.LibclangError: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

What I understand is that it fails to open a clang library, after searching for it, I found a lot of libraries at /usr/lib, and one of them is libclang.dll.a, I tried to make a symbolic link for it according some other SO questions suggest like:

ln -s /usr/lib/libclang.dll.a /usr/lib/libclang.so.1
ln -s /usr/lib/libclang.dll.a /usr/lib/libclang.so
ln -s /usr/lib/libclang.dll.a /usr/lib/python3.9/libclang.so.1
ln -s /usr/lib/libclang.dll.a /usr/lib/python3.9/libclang.so

but with no luck, any help as I'm not familiar with python.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source