The two days began to use Vim to learn the C + + language, the middle of the need to compile. Just wrote two small examples began to find that every time you have to quit vim to compile, it is too troublesome. That's when I thought
Before in a book on Vim to see the introduction of Quickfix, at that time because there is no need, this part is not serious to see, now that the use of, then began to study your use of her
The basic way to use this is to configure MAKEPRG, for example I want to use g++ to compile my C + +, I can configure set makeprg=g++\%\-o\%:r as follows. This allows the current file to be compiled directly from our vim using command line make.
Toss for two days, now finally can successfully use YCM, now record the process of installing this plug-in
I. Pre-conditions
1.vim Guaranteed above 7.3
Can be installed directly via sudo apt-get install vim under Ubuntu
2. Installing CMake
CMake is a more advanced build configuration tool than make, it can be based on different platforms, different compilers, the corresponding makefile or vcproj project
Can be installed via sudo apt-get install cmake under Ubuntu
Second, install the YCM plug-in
1. Add the Bundle ' Valloric/youcompleteme ' directly to the. VIMRC and run the Bundleinstall
Third, install llvm-clang3.9, Clang Standard library
1.clang
Clang is a lightweight compiler for C, C + +, Objective-c, C + + languages
Can be installed via sudo apt-get install clang
2.llvm
A compiler architecture system
3. If installed, download the precompiled file directly, unzip it, then copy it to the local directory/usr/local/.
Http://llvm.org/releases/download.html->Download LLVM 3.9.0->pre-built Binaries->clang for x86_64 Ubuntu 16.04 (. Sig)
4. Generate the search libraries required by ycm
Because I need to support C, C + +, so the compilation process is as follows
1) CD ~; mkdir Ycm_build; CD Ycm_build
2) In step 3 we have downloaded the CLANG+LLVM pre-compiled files, we extracted them to ~/ycm_temp/llvm_root_dir
3) Execute the following command cmake-g "<generator>"-dpath_to_llvm_root=~/ycm_temp/llvm_root_dir. ~/.vim/bundle/youcompleteme/third_party/ycmd/cpp
4) CMake--build. --target Ycm_core--config Release, she will generate a ycm_core.so under YCM
After several days of toss, finally put YCM installed, although said its specific role has not fully explored, but, from just a few kind, experience completely on more than one grade. The only thing that feels bad about Java is that it's not good enough, and if Java can do that, it's going to be a blast.
After this thing, a little touch is very deep, that is, we can always encounter strange problems, when encountering these problems, must not lose heart, try all kinds of programs, calm down to study the integration, always solve the problem. In addition, do not rely entirely on the network of ready-made solutions, mechanical attempts, it is better to calm down to study the cause of the problem. However, there is still a problem is not resolved, that is, Clang seems unable to support libc++ AH. This wait really affects your C + + learning time, and then solve it.
VIM-YCM plug-in installation