JBakamovic / yavide

Modern C/C++ integrated development environment
GNU General Public License v2.0
1.3k stars 137 forks source link

Debian issues with libclang #78

Open ks-zealot opened 6 years ago

ks-zealot commented 6 years ago

Just installed fresh instance of yavide. Clang autoformat doesnt working. For example, here my project scheme.

zealot@zealot:~/test1$ tree -a .
.
├── .clang_complete
├── .clang-format
├── Makefile
├── src
│   └── test.cpp
├── .yavide_proj
└── .yavide_session

.clang-format file was created with command clang-format -style=llvm -dump-config > .clang-format And in yavide my test.cpp looks like this

#include <iostream>

int foo(int a) { return a + 4; }

void main(int argc, char **argv) {

    int t = 1; }

and doesnt change after saving. When I manually run command, the file is properly formatted

zealot@zealot:~/test1/src$ clang-format -i test.cpp

zealot@zealot:~/test1/src$ cat test.cpp 
#include <iostream>

int foo(int a) { return a + 4; }

void main(int argc, char **argv) { int t = 1; }

How could I fix the problem? My installation log in attach. log.txt

JBakamovic commented 6 years ago

Seems strange. I can't reproduce the problem with your example on my machine. Can you please attach the yavide log? Location of log file is /tmp/<yavide_instance>_server.log where <yavide_instance> is YAVIDE, YAVIDE1, YAVIDE2, etc. Depends how many yavide instances you are running at the time ...

ks-zealot commented 6 years ago

Looks like yavide missed lib.

[INFO] [yavide_server.py:124]         yavide_server_run(): Starting a Yavide server ...
[INFO] [yavide_service.py:17]                  __init__(): Yavide instance: YAVIDE
[INFO] [yavide_service.py:18]                  __init__(): Actions: {0: <bound method SourceCodeModel.__startup_request of <services.source_code_model_service.SourceCodeModel instance at 0x7fe13b632f80>>, 1: <bound method SourceCodeModel.__shutdown_request of <services.source_code_model_service.SourceCodeModel instance at 0x7fe13b632f80>>, 2: <bound method SourceCodeModel.__request of <services.source_code_model_service.SourceCodeModel instance at 0x7fe13b632f80>>}
[CRITICAL] [yavide_server.py:99]          handle_exception(): Uncaught exception
Traceback (most recent call last):
  File "/opt/yavide/core/server/yavide_server.py", line 128, in yavide_server_run
    YavideServer(msg_queue, yavide_instance).listen()
  File "/opt/yavide/core/server/yavide_server.py", line 16, in __init__
    0x0 : SourceCodeModel(self.msg_queue, self.yavide_instance),
  File "/opt/yavide/core/services/source_code_model_service.py", line 14, in __init__
    self.parser = ClangParser()
  File "/opt/yavide/core/services/parser/clang_parser.py", line 71, in __init__
    self.index = clang.cindex.Index.create()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 2427, 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 3839, in lib
    lib = self.get_cindex_library()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3870, in get_cindex_library
    raise LibclangError(msg)
LibclangError: libclang.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

My libclang.so located here

zealot@zealot:~/Projects/mtum$ ls -lh /usr/lib/x86_64-linux-gnu/libclang-3.8.so lrwxrwxrwx 1 root root 17 июн 2 16:11 /usr/lib/x86_64-linux-gnu/libclang-3.8.so -> libclang-3.8.so.1

JBakamovic commented 6 years ago

Yes, it seems that is the case. If you look at the attached installation log, you will see that the libclang path selected by yavide is /usr/lib/llvm-3.8/lib/libclang.so. yavide tries to make its best guess during the installation where the libclang library is installed on your system and to do that it traverses the /usr/lib* directories. In your case, libclang.so is first found in /usr/lib/llvm-3.8/ directory and therefore selected.

To override that setting you should simply edit your local g:libclang_location to contain the correct path. That variable is set in .user_settings.vimrc file.

This should fix your problem.

ks-zealot commented 6 years ago

Nope, error still here. I edit config file, reopen yavide project and get same error. So, I check libclang from llvm and yes, its here.

zealot@zealot:~/Projects/mtum$ ls -lh /usr/lib/llvm-3.8/lib/libclang.so
lrwxrwxrwx 1 root root 40 июн  2 16:11 /usr/lib/llvm-3.8/lib/libclang.so -> ../../x86_64-linux-gnu/libclang-3.8.so.1
JBakamovic commented 6 years ago

Alright, now I realized there is something from installation log I can actually understand :)

LibclangError: libclang.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

Can you run the following on your machine and c/p the output here:

ldconfig -p | grep libclang.so

ks-zealot commented 6 years ago

No output lol. When I set less specified filter

zealot@zealot:~/Projects/mtum$ sudo /sbin/ldconfig -p | grep libclang
        libclang-3.8.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libclang-3.8.so.1
        libclang-3.8.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libclang-3.8.so
JBakamovic commented 6 years ago

Well, then that seems to be the problem as far as I can tell. libclang Python bindings cannot find the libclang.so because it is not in the path of the configuration of your dynamic linker/loader (ld).

Try to get this symbolic link into the correct path by i.e. reinstalling the libclang devel package (or some other step which is relevant to this problem for your distro) or create that symbolic link yourself. I would prefer to do in a right way, i.e. something on a track of the first option but if you want to a quick hack you can do the second one (which will break once you update the version of your libclang).

ks-zealot commented 6 years ago

Well, looks like symlinks is only way now. After creating symlink, I get the few different stacktrace

[CRITICAL] [yavide_server.py:99]          handle_exception(): Uncaught exception
Traceback (most recent call last):
  File "/opt/yavide/core/server/yavide_server.py", line 128, in yavide_server_run
    YavideServer(msg_queue, yavide_instance).listen()
  File "/opt/yavide/core/server/yavide_server.py", line 16, in __init__
    0x0 : SourceCodeModel(self.msg_queue, self.yavide_instance),
  File "/opt/yavide/core/services/source_code_model_service.py", line 14, in __init__
    self.parser = ClangParser()
  File "/opt/yavide/core/services/parser/clang_parser.py", line 71, in __init__
    self.index = clang.cindex.Index.create()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 2427, 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 3840, in lib
    register_functions(lib, not Config.compatibility_check)
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3787, in register_functions
    map(register, functionList)
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3785, in register
    return register_function(lib, item, ignore_errors)
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3766, in register_function
    raise LibclangError(msg)
LibclangError: /usr/lib/libclang.so: undefined symbol: clang_CXXConstructor_isConvertingConstructor. Please ensure that your python bindings are compatible with your libclang.so version.
JBakamovic commented 6 years ago

This looks like your Python bindings for libclang are not compatible with the version of libclang which you created a symlink for. In order to get this correct, you really need to install this dependency via your system package manager. Remove this newly created symlink and try to google around a bit how to install libclang dependencies for your system.

ks-zealot commented 6 years ago

Libclang deps on debian installed by command sudo apt-get install libclang-dev But, this package doesnt contains file libclang.so Could you provide information about libclang lib's version I needed for? For example from your desktop.

JBakamovic commented 6 years ago

I am not sure why is that so that you are missing libclang.so. That feels really strange. Version of libclang should not really matter until it is installed correctly. This is a problem very specific to your distro so I would try to google around to see if someone else had similar issues. I.e. here

Maybe installing Python bindings for libclang will help?

ks-zealot commented 6 years ago

Nope. Looks like its impossible make it work, sorry .(

JBakamovic commented 6 years ago

That's unfortunate but there must be a way to do it. Sorry that I can't help you more than this, I haven't got a Debian system at my place.

YuraCobain commented 6 years ago

Had the same issue. By manually downgrading python binding for clang to the version 3.8 fixed the problem:

sudo pip install https://pypi.python.org/packages/source/c/clang/clang-3.8.tar.gz

and creating symbolic link as well:

cd /usr/lib/x86_64-linux-gnu sudo ln -s libclang-3.8.so.1 libclang.so

ks-zealot commented 6 years ago

Yes, I could approve it, everything look fine