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

Problems compiling the plugin #1

Closed
kongo2002 opened this issue Jan 24, 2013 · 17 comments
Closed

Problems compiling the plugin #1

kongo2002 opened this issue Jan 24, 2013 · 17 comments

Comments

@kongo2002
Copy link

Hi, I am having little success with compiling the ycm_core plugin:

[ 96%] Building CXX object ycm/tests/CMakeFiles/ycm_core_tests.dir/IdentifierUtils_test.cpp.o
[ 97%] Building CXX object ycm/tests/CMakeFiles/ycm_core_tests.dir/IdentifierCompleter_test.cpp.o
Linking CXX executable ycm_core_tests
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommand_getArg'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommands_getSize'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommand_getNumArgs'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_defaultCodeCompleteOptions'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompilationDatabase_fromDirectory'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommands_getCommand'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_disposeTranslationUnit'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_defaultEditingTranslationUnitOptions'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getNumCompletionChunks'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_codeCompleteAt'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getFileName'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommands_dispose'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompileCommand_getDirectory'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_parseTranslationUnit'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getDiagnosticInSet'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getCString'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getNumDiagnostics'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getCompletionChunkCompletionString'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getCompletionAvailability'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getSpellingLocation'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getNumDiagnosticsInSet'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getChildDiagnostics'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_disposeIndex'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getDiagnosticLocation'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_createIndex'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getDiagnostic'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_disposeDiagnostic'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_reparseTranslationUnit'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getDiagnosticSeverity'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_disposeCodeCompleteResults'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_defaultDiagnosticDisplayOptions'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompilationDatabase_getCompileCommands'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getCompletionChunkText'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_formatDiagnostic'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_disposeString'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getCompletionChunkKind'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_getDiagnosticSpelling'
/home/kongo/.plugins/YouCompleteMe/python/ycm_core.so: undefined reference to `clang_CompilationDatabase_dispose'
collect2: ld returned 1 exit status
make[2]: *** [ycm/tests/ycm_core_tests] Error 1
make[1]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/all] Error 2
make: *** [all] Error 2

I am running on x86_64 gentoo linux with gcc 4.4.7. I tried the system installed clang 3.2 and the binaries on http://llvm.org/releases/download.html#3.2 without success.

Even passing the full path to libclang.so via -DEXTERNAL_LIBCLANG_PATH did not work either.

Any ideas?

Cheers,
Gregor

@Valloric
Copy link
Member

Tests are not being compiled successfully, which is not the end of the world (they should certainly compile and I'm looking into what might make them not compile for you, but you don't need the test executable to use YCM).

Instead of just doing make, try doing make ycm_core. Also, please paste the full cmake command line call you used.

@Valloric
Copy link
Member

Oh, and please paste the full output of the initial cmake call.

@Valloric
Copy link
Member

And while we're at it, paste the output of cmake --version.

@kongo2002
Copy link
Author

This is the run with the system installed clang 3.2

cmake version 2.8.9
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/lib64/llvm . ~/.plugins/YouCompleteMe/cpp
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Your C++ compiler does NOT support C++11, compiling in C++03 mode.
-- Found PythonLibs: /usr/lib64/libpython2.7.so (found version "2.7.3") 
Using libclang to provide semantic completion for C/C++/ObjC
-- Found PythonInterp: /usr/bin/python (found version "2.7.3") 
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found.
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kongo/.plugins/YouCompleteMe/build

@Valloric
Copy link
Member

Did running make ycm_core succeed without issues?

@kongo2002
Copy link
Author

You are right - building just ycm_core did succeed.

@kongo2002
Copy link
Author

I am having some trouble using it with syntastic though:

Messages maintainer: Bram Moolenaar <[email protected]>
"variations.cc" 68L, 1158C
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..SyntaxCheckers_cpp_GetLocList..youcompleteme#CurrentFileDiagnostics:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..<SNR>33_FilterLocList:
line    5:
E714: List required
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors:
line   12:
E706: Variable type mismatch for: errors
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..SyntasticAddToErrors:
line    3:
E715: Dictionary required
line    4:
E689: Can only index a List or Dictionary
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors:
line   15:
E712: Argument of extend() must be a List or Dictionary
Error detected while processing function youcompleteme#Enable:
line   38:
Traceback (most recent call last):
Error detected while processing function youcompleteme#Enable:
line   38:
  File "<string>", line 1, in <module>
Error detected while processing function youcompleteme#Enable:
line   38:
  File "/home/kongo/.plugins/YouCompleteMe/autoload/../python/ycm.py", line 26, in <module>
Error detected while processing function youcompleteme#Enable:
line   38:
    from completers.all.identifier_completer import IdentifierCompleter
Error detected while processing function youcompleteme#Enable:
line   38:
  File "/home/kongo/.plugins/YouCompleteMe/autoload/../python/completers/all/identifier_completer.py", line 23, in <module>
Error detected while processing function youcompleteme#Enable:
line   38:
    import ycm_core
Error detected while processing function youcompleteme#Enable:
line   38:
ImportError: /home/kongo/.plugins/YouCompleteMe/autoload/../python/ycm_core.so: undefined symbol: clang_CompileCommands_dispose
Error detected while processing function youcompleteme#Enable:
line   39:
Traceback (most recent call last):
Error detected while processing function youcompleteme#Enable:
line   39:
  File "<string>", line 1, in <module>
Error detected while processing function youcompleteme#Enable:
line   39:
NameError: name 'ycm' is not defined
Error detected while processing function youcompleteme#Enable..<SNR>89_OnBufferVisit..<SNR>89_SetCompleteFunc:
line    4:
E858: Eval did not return a valid python object
Error detected while processing function youcompleteme#Enable..<SNR>89_OnBufferVisit..<SNR>89_OnFileReadyToParse:
line    1:
Traceback (most recent call last):
Error detected while processing function youcompleteme#Enable..<SNR>89_OnBufferVisit..<SNR>89_OnFileReadyToParse:
line    1:
  File "<string>", line 1, in <module>
Error detected while processing function youcompleteme#Enable..<SNR>89_OnBufferVisit..<SNR>89_OnFileReadyToParse:
line    1:
NameError: name 'ycm_state' is not defined
Error detected while processing function <SNR>89_OnCursorMovedNormalMode..<SNR>89_UpdateDiagnosticNotifications:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_UpdateDiagnosticNotifications:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
Traceback (most recent call last):
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
  File "<string>", line 1, in <module>
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
NameError: name 'ycm_state' is not defined

Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_UpdateDiagnosticNotifications:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
Traceback (most recent call last):
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
  File "<string>", line 1, in <module>
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
NameError: name 'ycm_state' is not defined
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_UpdateDiagnosticNotifications:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
Traceback (most recent call last):
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
  File "<string>", line 1, in <module>
Error detected while processing function <SNR>89_OnCursorHold..<SNR>89_OnFileReadyToParse:
line    1:
NameError: name 'ycm_state' is not defined

This is my version information of vim:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 10 2013 22:10:21)
Included patches: 1-762
Modified by Gregor Uhlenheuer
Compiled by Gregor Uhlenheuer
Huge version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
-conceal -cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs 
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path 
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv 
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent 
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape 
+mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_sgr -mouse_sysmouse 
+mouse_urxvt +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg 
+path_extra -perl -persistent_undo +postscript +printer +profile +python 
-python3 +quickfix +reltime -rightleft +ruby +scrollbind +signs +smartindent 
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup +X11 +xfontset -xim 
+xsmp_interact +xterm_clipboard -xterm_save 
   system vimrc file: "/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: 
gcc -c -I. -Iproto -DHAVE_CONFIG_H     -march=athlon64 -O2 -pipe      
Linking: gcc   -L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined  -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -lelf -lnsl   -lcurses -lacl -lattr -lgpm -ldl     -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic   -Wl,-R -Wl,/usr/lib64 -L/usr/lib64 -lruby18 -lrt -ldl -lcrypt -lm  -L/usr/lib64   

@Valloric
Copy link
Member

WRT compile errors for the tests, don't worry about those; as long as ycm_core compiled, you're fine.

WRT runtime errors, I noticed this line in your error output:

ImportError: /home/kongo/.plugins/YouCompleteMe/autoload/../python/ycm_core.so: undefined symbol: clang_CompileCommands_dispose

Are you sure you have copied your libclang.so to the exact same directory as ycm_core.so, that is in YouCompleteMe/python? ycm_core.so will try to load libclang.so, and it appears that it's having difficulty doing so.

The other option is that the libclang.so that it is trying to load is not in fact clang 3.2. The missing symbol is clang_CompileCommands_dispose and it's part of an API that was added to libclang in Clang's latest release. The error you see is consistent with YCM trying to load a 3.1 libclang.so.

@Valloric
Copy link
Member

I just added the :YcmDebugInfo command that should make it easier for you to figure out exactly which version of Clang is in the libclang.so that Vim is loading. Make sure you open a clean instance of Vim (without trying to load any file) and then call the command. Please paste the output then. (Don't forget to pull in the latest changes from the repo and recompile.)

@kongo2002
Copy link
Author

Not working with your latest changes either. I just tried with the clang 3.2 download again. The new command does not work either:

Printing YouCompleteMe debug information...                                                                 
Error detected while processing function <SNR>78_DebugInfo:
line    2:
E858: Eval did not return a valid python object
-- 0

I fear I am missing something obvious here.

@Valloric
Copy link
Member

Most peculiar... don't worry, we'll get to the bottom of it (if you're willing to keep debugging that is).

The Eval did not return a valid python object error is hiding a traceback behind it which we can't see because it's wrapped inside pyeval. We need to see it.

Open a fresh instance of Vim (no file loaded). Then run the following command py import ycm; print ycm.YouCompleteMe().DebugInfo(). Paste what it prints out.

I have a nagging feeling that Vim is picking up the wrong libclang.so for you. You said that you have libclang.so available on your system and that it's version 3.2. The problem is that as soon as Clang pushes out a new release (let's say N), the development version is called N+1. So the libclang 3.2 your system comes with could potentially be a build of Clang "in-between" 3.1 and 3.2, calling itself 3.2 and not having the clang_CompileCommands_dispose symbol.

I just don't see why that specific symbol would be the one YCM borks on; if it couldn't find a libclang.so at all, you'd get a different error message. The fact that it's complaining about not being able to find this specific symbol makes me think that it's highly likely that it's loading some libclang.so, just not the right one.

I've personally had issues in the past with Vim picking up the system libclang.so instead of the one I placed in the YouCompleteMe/python folder. But I resolved those problems by messing with the RPATH in the ycm_core.so library so that it always tries to load its libraries from its own folder first... it could be that that workaround is somehow not working on your system.

@Valloric
Copy link
Member

Also, go into the python folder and run ldd ycm_clang.so. Paste the output of that please.

@Valloric
Copy link
Member

I was just able to reproduce this issue on one machine which means it will certainly be fixed; stand by.

@Valloric
Copy link
Member

Yes, I can now confirm that this issue arises if you try to use a 3.1 libclang.so with YCM instead of a 3.2 one.

I tested this by having a 3.1 libclang.so at /usr/lib/libclang.so and then starting Vim after installing YCM. I get the same spew of errors as you.

Are you 100% sure that you have copied a 3.2 libclang.so into YouCompleteMe/python? Judging from your error logs, on your machine, you should have copied a 3.2 libclang.so into /home/kongo/.plugins/YouCompleteMe/python.

For the record, running ldd ycm_core.so when the libclang.so is NOT in the correct place, I can see the following line in the output:

libclang.so => /usr/lib/libclang.so

That is wrong; it's going to load the system one, which is 3.1.

When I place the correct libclang.so in the same folder as ycm_core.so, I get this:

libclang.so => /home/valloric/.vim/bundle/YouCompleteMe/python/./libclang.so

That is correct, it's going to load 3.2 libclang.so I downloaded from llvm.org.

@kongo2002
Copy link
Author

Finally it seems to work!

I once again tried all different possibilities to pass the path to the clang lib. The -DEXTERNAL_LIBCLANG_PATH did the trick. Although I am not quite sure why the other variants did not work as well since my system wide clang is version 3.2.

On opening a C++ file I do get the following errors though:

Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..SyntaxCheckers_cpp_GetLocList..youc
ompleteme#CurrentFileDiagnostics:
line    1:
E858: Eval did not return a valid python object
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..<SNR>33_FilterLocList:
line    5:
E714: List required
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors:
line   12:
E706: Variable type mismatch for: errors
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors..SyntasticAddToErrors:
line    3:
E715: Dictionary required
line    4:
E689: Can only index a List or Dictionary
Error detected while processing function <SNR>33_UpdateErrors..<SNR>33_CacheErrors:
line   15:
E712: Argument of extend() must be a List or Dictionary
No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++

Are these errors caused by the missing .ycm_extra_conf.py?

@Valloric
Copy link
Member

Yes, you need to have a .ycm_extra_conf.py. See the docs. Without that file, YCM does not know how to compile your file.

Although CurrentFileDiagnostics should still return a valid Python object; I'll take a look at that.

@Valloric
Copy link
Member

I'm assuming you got it working. Please reopen and comment if otherwise.

@hardboydu hardboydu mentioned this issue Jul 4, 2016
bijancn pushed a commit to bijancn/YouCompleteMe that referenced this issue Jul 26, 2016
limbolily pushed a commit to limbolily/YouCompleteMe that referenced this issue Aug 9, 2016
This is disabled by default as support for it varies.
Cf. Cmake has unconditional out of tree support.

Fixes ycm-core#1
limbolily pushed a commit to limbolily/YouCompleteMe that referenced this issue Aug 9, 2016
limbolily pushed a commit to limbolily/YouCompleteMe that referenced this issue Aug 9, 2016
@ghost ghost mentioned this issue Sep 21, 2017
12 tasks
@dongleiw dongleiw mentioned this issue Apr 16, 2018
12 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants