10

I am using Linux Mint and I installed clang_complete using the makefile from Clang Complete, but it does not work. When I open a cpp file, there is an error message:

Loading libclang failed, completion won't be available. Consider setting g:clang_library_path

I already did some research on this topic and tried to find the libclang.so file to put g:clang_library_path= '...' into my vimrc, but I cannot find the file so I cannot define the path in my vimrc.

$ find / -name libclang -type f 2> /dev/null doesn't return anything.

How do I make clang_complete work?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user3476184
  • 101
  • 1
  • 1
  • 6

4 Answers4

21

You probably have libclang.so.1 in /usr/lib/x86_64-unknown-linux or somewhere similar. Make a symbolic link named as libclang.so in any of your library path would solve the problem (at least for me).

cd /usr/lib/x86_64-unknown-linux
ln -s libclang.so.1 libclang.so
xuhdev
  • 8,018
  • 2
  • 41
  • 69
11

You need to install libclang. On my Ubuntu system it is in the "libclang1" package. Clang compiler and libclang are in different packages.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Sandro
  • 2,707
  • 2
  • 20
  • 30
  • now there is a libclang.so.1 file in usr/lib/ . But defining usr/lib/ as clang_library_path does not change anything. still the same error. – user3476184 Mar 29 '14 at 18:31
  • ok :) usr/lib now contains libclang.so . But let clang_library_path= 'usr/lib' in my vimrc still doesn' t change anything... – user3476184 Mar 29 '14 at 18:55
  • you should use clang_library_path= '/usr/lib' not 'usr/lib' if it does not work remove clang_library_path variable. /usr/lib is default path. it should find library automatically there – Sandro Mar 29 '14 at 18:57
  • mhh it's still "loading liblang failed". Maybe I should try to install clang_complete again: Do you think https://github.com/Rip-Rip/clang_complete works? I did "git clone https://github.com/Rip-Rip/clang_complete.git" in my .vim directory and then "make install".. – user3476184 Mar 29 '14 at 19:09
  • Try to clone git repository to some other directory, and then do make install... I use clang_complete from git hub and it works fine. – Sandro Mar 29 '14 at 19:12
  • ok I removed it and installed it this way. it' s still not working. I ve installed omnigppcomplete before but deleted the directories in .vim . Do you have another idee maybe? – user3476184 Mar 29 '14 at 21:11
  • how can I check this? – user3476184 Mar 29 '14 at 21:23
  • vim --version | grep python you should see "+python" in the output. If there is "-python" then vim compiled without python support – Sandro Mar 29 '14 at 21:35
  • there is +python but -python3 – user3476184 Mar 29 '14 at 21:40
  • that's ok clang-complete does not need python3 I have no idea.... Does it still con't find library? Or something else? – Sandro Mar 29 '14 at 21:42
  • it 's still loading libclang failed – user3476184 Mar 29 '14 at 22:04
4

I ran into this issue with Ubuntu 20.04.3 LTS:

Loading libclang failed, completion won't be available. Are you sure '/usr/lib/x86_64-linux-gnu/libclang-6.0.so.1' contains libclang?

I fixed it using:

  1. Install libclang

    sudo apt install clang
    
  2. Add following in .vimrc to use latest installed libclang

    let g:clang_library_path = '/usr/lib/x86_64-linux-gnu/libclang-10.so.1'
    

If needed, adjust "libclang-10.so.1" to use the clang version that was installed.

You should be good with Vim at this point.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Sandeep
  • 41
  • 2
0

In $clang_complete/plugin/libclang.py, there is a code like this:

debug = int(vim.eval("g:clang_debug")) == 1

So use let g:clang_debug=1 to enable clang debug.

For me, the error is:

/lib64/libstdc++.so.6: version 'GLIBCCC_3.x.xx' not found

Set LD_LIBRARY_PATH and PKG_CONFIG_PATH to a third libstdc++ will solve this.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
James Lee
  • 21
  • 4