-
Notifications
You must be signed in to change notification settings - Fork 310
Home
Welcome to the clang_complete wiki!
If you want to build clang yourself, see http://clang.llvm.org/get_started.html. Otherwise see below for already built binaries of clang for easier installation.
sudo apt-get install clang
emerge clang
sudo port install clang
Or
brew install llvm --with-clang
On windows building clang is trickier, because when you build it with mingw it's slow as hell and when you build it with msvc it chokes on msvc's headers. The good news is that the -code-completion-at option still works, so all you have to do is to swallow clang's errors and make vim believe everything went fine. Follow the manual installation and add those lines to your .vimrc:
" The quotes at the beggining of clang_exec and at the end of clang_user_options are important, don't remove them
let g:clang_exec = '"C:\path\to\clang.exe'
let g:clang_user_options = '2> NUL || exit 0"'
Alternatively, you can download a prebuilt msvc 2008 binary to avoid going through the build process. If you use another compiler, or for some reasons you want to make it point to other system headers you can modify g:clang_user_options like this:
let g:clang_user_options = '-IC:\foo\bar "-IC:\path with spaces\keke" 2> NUL || exit 0"'
It is possible to build clang using MinGW and get a decent performance (see the benchmarks: https://github.com/Rip-Rip/clang_complete/issues/#issue/4/comment/566341). Following is a description of the method.
The instructions to build clang are based on those found in http://lyuts.net/blog/2010/06/llvm-clang-mingw.
- Get MinGW here - the automated installer. Install it to the default location.
- Get CMake here - the binary win32 installer. I got version 2.8. Install it. Again, do not change the defaults.
- Get LLVM and Clang source code here. I got version 2.8.
- Extract llvm sources. Let E:\LLVM be our working directory. After this step we are supposed to have llvm sources in E:\LLVM\llvm-2.8.
- Extract clang sources to E:\LLVM\llvm-2.8\tools. After this step we are supposed to have clang sources in E:\LLVM\llvm-2.8\tools\clang-2.8. However, this is not how it should be. Rename clang-2.8 to clang.
- Go to E:\LLVM\llvm-2.8. Create a build directory, let it be build.
- Open a command prompt (Run cmd.exe). Change the current directory to E:\LLVM\llvm-2.8\build.
- Run (this is a long line... do not forget to include the two dots ("..") in the end of the line): E:\LLVM\llvm-2.8\build>"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++ -static-libgcc --disable-shared --enable-static" -DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++ -static-libgcc --disable-shared --enable-static" -G "MinGW Makefiles" .. if you are on Windows 7 use this line (on Windows 7 CMake is installed to C:\Program Files (x86)\CMake 2.8\bin): E:\LLVM\llvm-2.8\build>"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++ -static-libgcc --disable-shared --enable-static" -DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++ -static-libgcc --disable-shared --enable-static" -G "MinGW Makefiles" ..
- After the configuring is done run C:\MinGW\bin\mingw32-make This will take some time to get llvm and clang built.
Instead of steps 3-5 you may get the sources using subversion (see http://clang.llvm.org/get_started.html, the section for unix-like systems).