sighingnow / libclang

(Unofficial) Release libclang (clang.cindex) on pypi.
https://pypi.org/project/libclang
Other
81 stars 21 forks source link

clang.cindex.LibclangError: libclang-14.so: cannot open shared object file #27

Closed g40 closed 2 years ago

g40 commented 2 years ago

Hello @sighingnow

This one is a bit of a mystery. Running my libclang based project from the command line (i.e. $python cppuml.py) works exactly as expected. If I create an executable file with `cx-freeze' it then fails with the following message:

clang.cindex.LibclangError: libclang-14.so: cannot open shared object file: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

Any thoughts on this? Please ask if you require more information. Additionally just say so f this is an upstream problem!

The same build process works perfectly on Windows (providing a path to the clang binaries is set).

MTIA.

$ pip show libclang
Name: libclang
Version: 13.0.0
Summary: Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier.
Home-page: https://github.com/sighingnow/libclang
Author: Tao He
Author-email: sighingnow@gmail.com
License: Apache License 2.0
Location: /home/moi/.local/lib/python3.8/site-packages
$uname -a
Linux ub-20 5.13.0-39-generic #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ which clang
/usr/bin/clang
$ clang -v
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
g40 commented 2 years ago

Belay all of the above. The work-around is shown below:

    # set the path to libclang *before* any other operations
    Config.set_library_file("/path/to/my/libclang.so")
sighingnow commented 2 years ago

I never tried that. I could take a look of the behaviour under cx-freeze.

sighingnow commented 2 years ago

I noticed that you have closed the issue. Has the issue been solved? or, still just a workaround here?

g40 commented 2 years ago

@sighingnow Still using my work-around but that is perfectly ok for my use-case where different versions/installations of clang may exist. See https://github.com/g40/cppuml-clang for the project.

sighingnow commented 2 years ago

I have fixed the issue in master and will cut the v14.0.0 release this weekend.