The final results and documents are
http://gist.github.com/zhuzhenpeng/5939304c8f298c82352b
GCC, Clang, LLVM concepts and relationships
Compiler sub-front and back end
Front-end mainly for syntax and semantic analysis, input is the source code, output is an abstract syntax tree, usually everyone said parser refers to the front end of the compiler
The backend mainly optimizes intermediate code and generates machine code, input is the syntax tree of the front end output is machine code, optimizer and code generator means backend
GCC contains both front and back ends, Clang is the front end, and LLVM is the back end. People use their combination to be (front end/back end):
gcc/gcc
Gcc/llvm
Clang/llvm
CLANG/LLVM is being pushed by Apple.
Clang provides a powerful semantic analysis capability.
Youcompleteme
The foreigner writes a very good code complements the tool, the principle is uses the C/s structure, the editor as the client, the backstage feedback complements the entire information, and these complete information is uses the Clang tool to obtain.
Http://github.com/Valloric/YouCompleteMe
It is said that it can also be used in Emacs, Emacs itself lacks c++11 syntax highlighting, and the completion of the tool at present in addition to rtags involving c++11 other seems to be unsatisfactory, ycm should be very good (I did not try)
Http://github.com/Valloric/ycmd, this is a service-side project.
Vim Installation and Configuration ycm
The installation steps that the foreigner said on GitHub are very clear.
Under Ubuntu, I also use Vundle, in the inside add a sentence Plugin ' valloric/youcompleteme ' Let it keep under (the process a little long, always show processing XXX)
Until Undle prompts me to compile, this time go to the directory to execute
./install.sh --clang-completer
就可以了
Configuration
. ycm_extra_conf.py file
The configuration of this file is the main purpose of my writing this article.
The official demo address is http://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py.
First of all, let's say. ycm_extra_cong.py, in general, each project needs to have a corresponding file in the root directory, whenever the source code is opened in a project project with VIM, the Ycmd server will search from the directory in which it is located until this is found. ycm_ extra_cong.py file, and then according to this file to obtain the source code needed to complete the information.
So the key is to tell the Ycmd server to use the location of the header files, for example, if it is a QT project, you can put the corresponding files to tell ycmd, otherwise you will not be the QT code prompts.
According to the official statement, we can mainly modify Falgs. In Falgs, we see the-I (Caps I) and-isystem, according to the GCC man, saying:
-I. Dir
Add the directory dir to the list of directories to be searched Forheader files. directories named by-i is searched before the standard system include directories.
-isystem dir
Search dir for headers files, after all directories specified by-i but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as was applied to the standard system directories .
So we put the header file in our project in the folder behind-I, and the C + + library header file, QT Library header file behind the-isystem
In some tutorials on the web, some say that the default profile is written to. VIMRC
~/.vim/bundle/youcompleteme/cpp/ycm/.ycm_extra_conf.py
At least now it seems to be wrong, the current folder in this YCM project has changed a lot, the original folder has been changed location and even no
In other tutorials, many people refer directly to the buddy's profile
http://gist.github.com/locojay/4950253
Some people may succeed but do not know why, some people think it is successful but not actually (most of the cases are not prompted)
Libc++-dev
In fact, we need the addition of C + +, and most importantly, the location of gathered up C + + header file, and put it in-isystem
Take my current machine for example, under Ubuntu, turn to the/usr/include/c++/4.8/directory, see the file known as vector, open to see the content is
。。。
#include <bits/stl_vector.h>
。。。
You can see that the vector's declaration was placed in the Stl_vector.h file, and I tried to add/usr/include/c++/4.8/and all its subfolders to the flags but it didn't work, and when used, it showed no vector definition. I don't know if it's because of the name.
And then my solution was
sudo apt-get install Libc++-dev
This libc++-dev is a new 11-based implementation of the C + + standard library, LLVM C + + standards libraries development files
After installation can see the /usr/include/c++/v1 folder put all the header file, at this time put it into the configuration file is done, all the complements are prompted.
You can set this basic configuration file that contains only the base library to be global so that you do not have to configure it for a temporary C + + file:
let g:ycm_global_ycm_extra_conf = ‘your/path/to/.ycm_extra_cong.py‘
Can find /usr/include/c++/v1 and the network of the/USR/LIB/C++/V1 configuration is very similar, but now the header files have been placed elsewhere, I do not have that folder on the machine. So a little understanding of the principle is still necessary, in the future, just find
Vim's ycm (youcompleteme) plug-in configuration