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 locating libclang.so on Debian/Ubuntu systems #2

Closed
rhdunn opened this issue Feb 13, 2013 · 14 comments
Closed

Error locating libclang.so on Debian/Ubuntu systems #2

rhdunn opened this issue Feb 13, 2013 · 14 comments

Comments

@rhdunn
Copy link
Contributor

rhdunn commented Feb 13, 2013

On Debian and Ubuntu systems, libclang is provided by the libclang1 package. This installs /usr/lib/libclang.so.1 on amd64 and i386 systems, not /usr/lib/libclang.so (see e.g. http://packages.ubuntu.com/raring/amd64/libclang1/filelist).

This means that running cldoc I get the error:

Traceback (most recent call last):
  File "/usr/local/bin/cldoc", line 5, in <module>
    cldoc.run()
  File "/usr/local/lib/python2.7/dist-packages/cldoc/__init__.py", line 152, in run
    generate(opts, cxxflags)
  File "/usr/local/lib/python2.7/dist-packages/cldoc/__init__.py", line 23, in generate
t.process()
  File "/usr/local/lib/python2.7/dist-packages/cldoc/tree.py", line 200, in process
    index = cindex.Index.create()
  File "/usr/local/lib/python2.7/dist-packages/cldoc/clang/cindex.py", line 1862, in create
    return Index(conf.lib.clang_createIndex(excludeDecls, 0))
  File "/usr/local/lib/python2.7/dist-packages/cldoc/clang/cindex.py", line 153, in __get__
    value = self.wrapped(instance)
  File "/usr/local/lib/python2.7/dist-packages/cldoc/clang/cindex.py", line 3096, in lib
lib = self.get_cindex_library()
  File "/usr/local/lib/python2.7/dist-packages/cldoc/clang/cindex.py", line 3127, in get_cindex_library
    raise LibclangError(msg)
cldoc.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().
@jessevdk
Copy link
Owner

You will need to install libclang-dev instead.

@rhdunn
Copy link
Contributor Author

rhdunn commented Feb 13, 2013

Strictly speaking, libclang-dev should only be used if you are building something that is interfacing with clang. When running the built program, it should depend on libclang1. That is, you don't need to install the *-dev packages of other components just to use the library that component provides.

Thanks for this info -- it would be worth mentioning it in the getting started page.

@jessevdk
Copy link
Owner

I've mentioned it now. I know that the .so is for development normally. The problem is with the clang python bindings which only looks for the unversioned .so. I'll see if this can be fixed in the future.

@refi64
Copy link

refi64 commented Dec 29, 2013

Why not use something like this:

from ctypes.util import find_library
# ...
Config.set_library_file(find_library('clang'))

@jessevdk
Copy link
Owner

jessevdk commented Jul 8, 2014

I'm using this now, at least for linux. It seems to be working fine.

@jessevdk jessevdk closed this as completed Jul 8, 2014
@cosmicexplorer
Copy link

Hey, this didn't work for me. I had to manually add the line Config.set_library_path("/usr/lib/llvm-3.4/lib") to line 3100 of /usr/local/lib/python2.7/dist-packages/cldoc/clang/cindex.py to make it stop complaining. Setting LD_LIBRARY_PATH in the shell didn't help, so I had to make that change. This was on Ubuntu 14.04.

@grvlbit
Copy link

grvlbit commented Dec 15, 2014

I encountered the same issue as @cosmicexplorer. The problem with Ubuntu (at least 14.04) seems to be the name of the libclang.so file. In /usr/lib/x86_64-linux-gnu/ the file is called libclang.so.1 which is then not found by cldoc causing the error.

Therefore I propose a less restrictive lib file search to fix this issue. Since I am not that fluent in Python I cannot provide the patch myself.

A workaround is creating a symlink in /usr/lib/x86_64-linux-gnu/ as ln -s libclang.so.1 libclang.so

@Wallacoloo
Copy link

I was faced with the same issue on Ubuntu 14.10 after installing via pip. gujans symlink solution worked for me. Unless this has been fixed in the github code and not yet published to pip, I think this issue should be reopened.

@jessevdk
Copy link
Owner

Can you try with current master and let me know if that solves the issue?

@Wallacoloo
Copy link

Tested with master and it works just fine. Sorry for the trouble.

@jessevdk
Copy link
Owner

I will make a new release soon so this gets picked up.

@lzuwei
Copy link

lzuwei commented Mar 29, 2015

I am having some issues on MacOSX Yosemite,
cldoc is complaining about libclang.dylib

it is located in /Library/Developer/CommandLineTools/usr/lib/libclang.dylib on my machine.
Is there an easy way to point to this?

cldoc.clang.cindex.LibclangError: dlopen(libclang.dylib, 6): image not found. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

@jessevdk
Copy link
Owner

This should have been fixed in 1.7.

@tsteinholz
Copy link

I installed cldoc via the pip yesterday. It is installed in /usr/local/bin/cldoc but I get the same issue with not finding clang. I have both clang and the dev version of clang. I have attempted the system link trick (which didn't work) and my project is up to date. What can I do?

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

8 participants