Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running: "libclang.so: cannot open shared object file: No such file or directory" #6

Open
Tracked by #212
stepthom opened this issue Aug 21, 2015 · 2 comments

Comments

@stepthom
Copy link

First, I ran sudo apt-get install python-yaml and sudo pip install clang. Success.

Then I tried:

[dev@ubuntu:~/cncc (master)] $ ls
cncc  examples  LICENSE  MyClass.cpp  MyClass.h  README.md  util
[dev@ubuntu:~/cncc (master)] $ git log -1
commit 4529cb3536c7cec20ea0bb850d0f95e80cded733
Author: Daniel J. Hofmann <daniel@trvx.org>
Date:   Wed Aug 19 14:55:48 2015 +0200

    Respect global style file, closes #5

    Local style files do not seem to make a lot sense. What we could do is
    walk all parent directories like `clang-format` does, though.
[dev@ubuntu:~/cncc (master)] $ cat MyClass.h 
class MyClass{
public:
    void init(int a, int b);
    int loopAlot();
private:
    int var1, var2;
};

[dev@ubuntu:~/cncc (master)] $ cat MyClass.cpp 
#include "MyClass.h"

void MyClass::init(int a, int b){
    var1 = a;
    var2 = b;
}

int MyClass::loopAlot(){
    int res = this->var1 + var2;
    for(int i=0; i<this->var1; ++i){
        res = res + this->var2;
    }
    return res;
}
[dev@ubuntu:~/cncc (master)] $ ./cncc --style=examples/basic.style MyClass.cpp
Traceback (most recent call last):
  File "./cncc", line 22, in <module>
    index = I.create()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 2119, in create
    return Index(conf.lib.clang_createIndex(excludeDecls, 0))
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 141, in __get__
    value = self.wrapped(instance)
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3429, in lib
    lib = self.get_cindex_library()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3460, in get_cindex_library
    raise LibclangError(msg)
clang.cindex.LibclangError: libclang.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 idea what I'm doing wrong?

@daniel-j-h
Copy link
Contributor

Sorry for not responding earlier, seems like I overlooked the notification.

You do not have a matching libclang native shared library for the Python wrapper that python-clang is supposed to wrap. I found PyPI to not provide wrappers compatible with every clang version. That is, check your clang --version, and then see if PyPI has a matching wrapper for this (I think the one for 3.6 was missing, and e.g. Ubuntu 15.04 comes with Clang 3.6).

That's the main reason this issue was never resolved.

The easiest way to install python-clang is by means of your package manager, e.g. aptitude on Debian-based systems.

@gfdac
Copy link

gfdac commented Feb 7, 2017

Hi, for who have problem with python-clang, make a simbolic link for the same version of native clang and the python-bind:
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libclang-3.8.so.1 libclang.so
cheers []s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants