Skip to content
This repository

Windows Installation Guide 

nop00 edited this page · 30 revisions
Clone this wiki locally

Please note that there is no official YCM support for Windows, so don't complain if these instructions don't work for you. You are encouraged to improve this Wiki page and send pull requests that improve Windows support, but DON'T create issues on the tracker asking for Windows-related code changes or docs.

Before starting this installation procedure, it's critically important that you understand that the architecture (x86 vs x86-64) that you build ycm_core.pyd for has to match the architecture of the python27.dll on your system and the architecture of the Vim binary you will be running. All three need to match, otherwise things won't work.

Vim YouCompleteMe for Windows

If you are not a masochist, then it's probably better to download pre-built and ready-to-use distributions of YCM for Windows. One reliable option is Vim YouCompleteMe for Windows. Both x86 and x64 architectures are supported. The installation guide and coverage of common pitfalls are included.

Instructions for 64-bit using Visual Studio 2012 Express

Here's a sequence of steps that worked on Windows 7 x64. These instructions build YCM without semantic support for C-family languages.

  1. Install Visual Studio 2012 Express for Windows Desktop.
  2. Download Python 2.7 x86-64 for Windows.
  3. IMPORTANT: You need to have a 64-bit build of Vim for YCM to work. Haroogan has 64-bit builds that are confirmed working.
  4. Install CMake.
  5. Install Vundle.
  6. Install YCM with Vundle.
  7. Create a build directory and cd into it.
  8. Run cmake -G "Visual Studio 11 Win64" . <USERFOLDER>\vimfiles\bundle\YouCompleteme\third_party\ycmd\cpp
    • If it fails by saying that Python could not be found, then do the following:
      1. Delete everything in your build directory first.
      2. Make sure you installed Python 2.7 x64, not x86.
  9. Open the SLN file in VS2012, change to Release mode (Build -> Config Manager -> Active Solution Config -> Release in VS2012) and build just the ycm_core project by right clicking on it in the Solution Explorer and choosing Project Only -> Build Only ycm_core. You'll probably see tons of warnings during the build; ignore them. If you get the error about ..\BoostParts\Release\BoostParts.lib missing, build BoostParts first using the same right click menu, then build ycm_core again. The build product will be a ycm_core.pyd in your YouCompleteMe\python folder.
    • You can also build it from the command line with msbuild (Normally located in C:\Windows\Microsoft.NET\Framework64\v4.0.xxxxx): msbuild /t:ycm_core /property:configuration=Release YouCompleteMe.sln
  10. Copy ycm_core.pyd from ycm\Release to <USERFOLDER>\vimfiles\bundle\YouCompleteMe\python if it's not there already.

If you want semantic support for C-family languages, look for instructions below.

Note that Clang's support for Windows is still very experimental; if you try to enable C-family semantic support in YCM using a libclang you compiled yourself (or got somewhere else, doesn't matter), it's possible you'll have Vim locking up and/or crashing on some C/C++/Objective-C files. If this happens, try to compile your file with the raw clang binary, using the same flags that YCM is giving libclang (you can see those by calling :YcmDebugInfo with your file as the active buffer). If clang fails to compile the file, you've encountered a clang issue, not a YCM one.

Instructions for 64-bit using MinGW64

Here's a sequence of steps that worked on Windows 8 x64. These instructions build YCM without semantic support for C-family languages.
IMPORTANT: If you use version 4.8.1 or greater it is very likely that error undefined reference to `InterlockedCompareExchange' will occur. In that case use earlier version of compiler or after step 6. replace file cpp\BoostParts\boost\detail\interlocked.hpp with that file.

  1. Download the -win64 version of MinGW64. Extract the archive to C:\MinGW64 and add C:\MinGW64\bin to your PATH
  2. Install Python 2.7 x86-64 for Windows.
  3. IMPORTANT: You need to have a 64-bit build of Vim for YCM to work. Haroogan has 64-bit builds that are confirmed working.
  4. Install CMake.
  5. Install Vundle.
  6. Install YouCompleteMe using Vundle.
  7. Edit %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp\CMakeLists.txt and add the following lines:
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -include cmath")
    add_definitions(-DBOOST_PYTHON_SOURCE)
    add_definitions(-DBOOST_THREAD_BUILD_DLL)
    add_definitions(-DMS_WIN64)
  8. Edit %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp\ycm\ycm_core.cpp and comment out the last three lines so they look like this:
    // namespace boost {
    // void tss_cleanup_implemented() {}
    // };
  9. Create a build directory and cd into it.
  10. Run cmake -G "MinGW Makefiles" . %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp. If you have ever renamed the MinGW's make program (originally mingw32-make.exe), then you should probably add the following argument to let cmake know where to find it: -D"CMAKE_MAKE_PROGRAM:PATH=C:/MinGW64/bin/NAME-OF-YOUR-MAKE.exe"
  11. Run mingw32-make ycm_core (Don't worry about the 32 in that command)
  12. Copy ycm_core.pyd from ycm\ to %USERPROFILE%\vimfiles\bundle\YouCompleteMe\python

Instructions for 64-bit using MinGW64 (clang)

Here's a sequence of steps that worked on Windows 7 x64. These instructions build YCM with semantic support for C-family languages.

  1. Download the -win64 mingw-builds version of MinGW-w64. Extract the archive to C:\MinGW64 and add C:\MinGW64\bin to your PATH
  2. Install Python 2.7 x86-64 for Windows to C:\Python27.
  3. You can try to make libpython27.a or download from here (tip: you can unpack installer with 7-Zip). Make sure that you put libpython27.a in C:\Python27\libs directory.
  4. Compile LLVM with clang or download again from Haroogan. Click on proper number in download section to download LLVM. Unpack it to C:\LLVM
  5. You need to have a 64-bit build of Vim for YCM to work. Haroogan has 64-bit builds that are confirmed working.
  6. Install CMake.
  7. Install:
    • Vundle and install YouCompleteMe using Vundle
    • OR Pathogen, make dir in vimfiles\bundle\YouCompleteMe, cd in Git Bash into it and run:
      git clone https://github.com/Valloric/YouCompleteMe .
      git submodule update --init --recursive
  8. Replace file %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp\BoostParts\boost\detail\interlocked.hpp with that file.
  9. Edit %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp\CMakeLists.txt and add the following lines:
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -include cmath")
    add_definitions(-DBOOST_PYTHON_SOURCE)
    add_definitions(-DBOOST_THREAD_BUILD_DLL)
    add_definitions(-DMS_WIN64)
  10. Create a build directory and cd into it.
  11. Run cmake -G "MinGW Makefiles" -DPATH_TO_LLVM_ROOT=C:\LLVM . %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp. If you have ever renamed the MinGW's make program (originally mingw32-make.exe), then you should probably add the following argument to let cmake know where to find it: -D"CMAKE_MAKE_PROGRAM:PATH=C:/MinGW64/bin/NAME-OF-YOUR-MAKE.exe"
  12. Run mingw32-make ycm_support_libs (Don't worry about the 32 in that command)
  13. Copy ycm_core.pyd, ycm_client_support.pyd, and libclang.dll from ycm\ to %USERPROFILE%\vimfiles\bundle\YouCompleteMe\python

Possible errors:

  • "cmake exit with error and linking to wrong compilers/libraries"
    • Check if you have YouCompleteMe and build directory on the same drive (in this guide C:\) as MinGW, Python and LLVM.
  • "during linking stage occurs undefined reference to `Interlocked...' error"
    • If you are sure that you made step 8. correctly, then probably is error in boost libraries. Wait for update of YouCompleteMe's Boost library or use Google to resolve that issue and then update wiki, please.
  • "during compiling stage occurs undefined reference to `__imp__Py_...'"
    • delete all files from build directory, check if libpython27.a is in C:\Python27\libs directory and repeat from step 11. Check if cmake found libpython27.a.

Instructions for Cygwin (non-clang)

Make sure to use the Cygwin packages of python, gcc4, and cmake--not the downloadable windows binaries of CMake and Python.

If you use Cygwin 64bit you may see an error regarding LONG BIT improperly defined, to fix see issue 684 for instructions on patching boost.

  1. Compile VIM (might not be necessary if the cygwin Vim version is greater than 7.3.538): https://gist.github.com/saamalik/5808448
  2. Install the following packages through Cygwin setup.exe: python, gcc4, CMake, and make. Versions I used: python-2.7.3-1, gcc-4.5.3-3, and cmake-2.8.9-2,
  3. cd ~/.vim/bundle/YouCompleteMe
  4. mkdir build_cygwin && cd build_cygwin
  5. cmake -G "Unix Makefiles" . ../cpp # ignore the legacy cygwin error bla bla bla
  6. make ycm_core
  7. make ycm_client_support
  8. cd ~/.vim/bundle/YouCompleteMe/python/
  9. cp ~/.vim/bundle/YouCompleteMe/build_cygwin/ycm/ycm_core.pyd ycm_core.dll # notice the extension rename--cygwin python imports dll, pyc, and py extensions (NOT pyd)
  10. cp ~/.vim/bundle/YouCompleteMe/build_cygwin/ycm/ycm_client_support.pyd ycm_client_support.dll

I've uploaded my compiled version to (2013-08-31): https://github.com/saamalik/dotvim/tree/master/windows/windows_binaries

Instructions for Cygwin (clang)

Note: This is very naive manual, somebody should be able to do it better. I am writing it from my memory.

If you use Cygwin 64bit you may see an error regarding LONG BIT improperly defined, to fix see issue 684 for instructions on patching boost.

Make sure to use the Cygwin packages of python, gcc4, and cmake--not the downloadable windows binaries of CMake and Python. Be sure that you are NOT using cygwin clang packages. You cannot use cygwin clang, because there is an old version of it. (you need at least version 3.2). Following note has been taken with clang 3.4.
1. Download and compile LLVM and clang and follow their manual http://clang.llvm.org/get_started.html
2. I was not able to finish make with LLVM/CLANG under the cygwin (with cmake generated Makefiles), but if you are, you should have clang installed in /usr/local/ directory.
If make fails for you too in the test phase (after message "Linking CXX executable ../../../../bin/c-index-test.exe" message), follow 3 else follow 6.
3. Copy llvm/include into the /usr/local/include
4. Copy llvm/tools/clang/ /usr/local/include
5. Copy directories {bin, include, lib, share} from your clang build directory into the /usr/local
6. Compile YCM:
cd ~/.vim/bundle/YouCompleteMe
mkdir build_cygwin && cd build_cygwin
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/local -DTEMP=/usr/local/bin/cygclang.dll . ../cpp
make ycm_core
7. cp ~/.vim/bundle/YouCompleteMe/build_cygwin/ycm/ycm_core.pyd ycm_core.dll # notice the extension rename--cygwin python imports dll, pyc, and py extensions (NOT pyd)

Instructions for 32-bit

You will need Visual Studio Express installed, or you can also install the Windows SDK, which are the command-line only tools. These instructions are mostly minor modifications to the more detailed 64-bit instructions above, but for brevity here they are as follows:

  1. Install the latest version of Cream. This distribution contains 32-bit installers of Vim with the latest patches and is updated regularly. YCM requires at least 7.3.584 installed.
  2. You will need 32-bit versions of Python and CMake. If you have Chocolatey, you can cinst python.x86 and cinst cmake, otherwise you will need to install these manually.
  3. Install YCM with Pathogen/Vundle/etc.
  4. Open a command prompt with the SDK utilities included in the PATH (e.g. msbuild.exe is in the %PATH%).
  5. cd path\to\ycm
  6. cmake -G "Visual Studio 11" cpp
  7. msbuild /t:ycm_core;ycm_client_support /property:configuration=Release YouCompleteMe.sln
  8. copy ycm\Release\ycm_core.pyd python
  9. copy ycm\Release\ycm_client_support.pyd python

Instructions for compiling YCM with Clang support

Now prebuilt Clang snapshots are available on the LLVM snapshot builds site. you don't need to compile it yourself, get latest Windows snapshot build from that page.

  1. Install all requirements from the instructions above. Dont compile anything yet.
  2. Create a build directory and cd into it.
  3. Suppose you are've successfully installed Clang from installer in a C:\LLVM dir. Now, run cmake -G "Visual Studio 11" -DPATH_TO_LLVM_ROOT=C:\LLVM . <USERFOLDER>\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp. Dont forget to change a VS version and a path to Clang build dir if you are using different VS version or build path.
  4. Now build ycm_core solution. If you are getting errors like:
    • 'boost::bind' : ambiguous call to overloaded function. This issue was fixed, try updating to the latest version of YCM.
    • unresolved external symbol __imp__clang_createIndex - that means that linker cant find Clang libraries. Check your path specified in Configuration Properties -> Linker -> Input -> Additional Dependencies field.
  5. If building successfully finished, copy ycm_core.pyd from ycm\Release and libclang.dll from C:\build\bin\Release to <USERFOLDER>\vimfiles\bundle\YouCompleteme\python.
Something went wrong with that request. Please try again.