ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.43k stars 2.81k forks source link

could not read symbols: File in wrong format #96

Closed elken closed 11 years ago

elken commented 11 years ago

Running fully patched Ubuntu 12.04 32-bit I'm able to generated makefiles and make it fine, but after running vim I get that.

vim -version

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb  9 2013 21:41:41)
Included patches: 1-806
Compiled by ed@Ubu-La0
Huge version with GTK2 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_gui +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: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim73"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic  -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl    -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib

I've tried building libclang from source and from repos, still with no avail.

How I installed

Valloric commented 11 years ago

When do you get the could not read symbols: File in wrong format error? What were you doing to get it etc.

elken commented 11 years ago

Ok, that was fixed by an unmet dependency, but now I can't autocomplete anything. Typing anything just gives -- User defined completion (^U^N^P) Pattern not found

:YcmDiags givers

Filetype completion not supported for current file, cannot force recompilation.
Forcing compilation, this will block Vim until done.
Unable to retrieve diagnostics.
No warnings or errors detected
Press ENTER or type command to continue

:YcmDebugInfo gives

Printing YouCompleteMe debug information...
-- Has Clang support compiled in: True
-- clang version 3.3 (trunk 174836)
Press ENTER or type command to continue

vim --version gives

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb  9 2013 21:41:41)
Included patches: 1-806
Compiled by ed@Ubu-La0
Huge version with GTK2 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_gui +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: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim73"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic  -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl    -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   
Valloric commented 11 years ago

The semantic completion engine only works with C++/C/Objective-C/Objective-C++. Look at the output of set ft?.

elken commented 11 years ago

I know it only works with C related languages, I was trying it on a .cpp file. On every extension, it comes up blank.

fvdnabee commented 11 years ago

I'm having the same issue, when typing "this->" in Insert mode I get User defined completion (^U^N^P) Pattern not found. The file has a .cc extension, set ft? returns "filetype=cpp" as output.

Some additional info: :YcmDebugInfo Printing YouCompleteMe debug information... -- Flags for /home/fvdabeele/src.cc: -- [] -- Has Clang support compiled in: True -- clang version 3.2 (tags/RELEASE_32/final)

:YcmDiags Forcing compilation, this will block Vim until done. Unable to retrieve diagnostics. No warnings or errors detected

:YcmForceCompileAndDiagnostics Forcing compilation, this will block Vim until done. Unable to retrieve diagnostics.

:YcmShowDetailedDiagnostic No diagnostics for current line!

I installed ycm using the Full installation guide on http://valloric.github.com/YouCompleteMe/. I am using Pathogen instead of of Vundle. I compiled vim myself as illustrated on https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source.

I'm guessing something went wrong during installation or that ycm can't find/parse my code files for some reason. However, I don't know how to debug the problem any further. Any suggestions?

Valloric commented 11 years ago

Look at the output of :messages after you try to use the semantic completions and get nothing. Paste the output here.

fvdnabee commented 11 years ago

It appears that I didn't read through the entire documentation as I had forgotten to make a .ycm_extra_conf.py file for my project. After creating the file and typing "this->" I get more than 3000 suggestions, I don't suppose this is normal behavior? I have noticed that the clang compiler doesn't like the Click modular router code that I'm including (more specifically it doesn't like a macro that defines a namespace, this does work with GCC), so I'm guessing this might be the cause of the 2000+ suggestions? Guess I would have to get Click working with clang.

Valloric commented 11 years ago

If you get a large number of suggestions from clang, that means it was unable to compile your file and thus build a correct AST from it.

fvdnabee commented 11 years ago

Thanks for the pointers so far, Valloric. I've managed to compile my project with LLVM using the Makefile that ships with Click (i.e. an external 'framework' in which my code is implemented). However when ycm compiles my project I'm getting strange build errors via syntactic that I don't see when I compile my code on cmd line with the Makefile. So it is my understanding that I should construct a correct .ycm_extra_conf.py file from the Makefile and that this would allow ycm to properly build my project. However, can't I just supply the location of the existing Makefile to ycm directly, instead? edit: is it possible to see which command ycm uses to compile a file? If I could cross reference this with the output from the Makefile I might be able to construct a corresponding .ycm_extra_conf.py file.

Valloric commented 11 years ago

:YcmDiags will show you all of the flags that YCM passes to libclang for the current file. This will include all of the flags you return from your FlagsForFile() method in ycm_extra_conf and some other flags for clang system headers.

tekmanBlade commented 10 years ago

When I am editing the cpp files under source file folder unde YouCompleteMe/cpp. It works perfectly.

But when I am editing my own cpp project, when typing "this->" in Insert mode I get User defined completion (^U^N^P) Pattern not found. The result from :YcmDiags is like the following for my own project source files. "attrib/core/lbraAttr.cc|13 col 10 error| 'lbraAttr.h' file not found with include; use "quotes" instead attrib/core/lbraAttr.cc|14 col 10 error| 'lbraLibrary.h' file not found"

Is it because missing header files so that I always get "Pattern not found.“