-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Windows Installation Guide for Unix‐like Environments
Windows is officially supported by YouCompleteMe (using MSVC). Please follow the instructions in the README.md. This page is for installing YCM on Unix-like environments (Cygwin, MinGW, MSYS2) and is community maintained. Do NOT create an issue if these instructions are not working for you.
- Download the latest version of MSYS2 and add it to your PATH
- Install Python 3.8 x86-64 for Windows.
- Install Vim 64-bit from these builds
- Install YouCompleteMe using Vundle
- Run the below commands in the msys2 terminal:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-python git msys2-runtime-devel
export PATH=/mingw64/bin/:$PATH
cp /usr/lib/librt.a /mingw64/lib
cd /c/users/<USERNAME> # <USERNAME> is your windows username
mkdir ycm-build
cmake -G "Unix Makefiles" . /c/<PATH TO YouCompleteMe>/third_party/ycmd/cpp
cmake --build . --target ycm_core --config Release
python -m pip install watchdog
- If you are using Vim on native Windows, add this to the top of you
vimrc
:
let &pythonthreedll="<PATH TO YOUR PYTHON INSTALLATION>\\python38.dll" "E.g.:C:\\Python\\python38.dll
let g:ycm_server_python_interpreter="<PATH TO MSYS2 INSTALLATION>\\mingw64\\bin\\python" "E.g.: C:\\MSYS2\\mingw64\\bin\\python
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.
- Download the -win64 version of MinGW64. Extract the archive to
C:\MinGW64
and addC:\MinGW64\bin
to your PATH - Install Python 2.7 x86-64 for Windows.
- IMPORTANT: You need to have a 64-bit build of Vim for YCM to work. Haroogan has 64-bit builds that are confirmed working.
- Install CMake.
- Install Vundle.
- Install YouCompleteMe using Vundle.
- 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)
- 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() {}
// };
- Create a
build
directory andcd
into it. - Run
cmake -G "MinGW Makefiles" . %USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp
. If you have ever renamed the MinGW's make program (originallymingw32-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"
- Run
mingw32-make ycm_core
(Don't worry about the32
in that command) - Copy
ycm_core.pyd
fromycm\
to%USERPROFILE%\vimfiles\bundle\YouCompleteMe\python
Here's a sequence of steps that worked on Windows 7 x64. These instructions build YCM with semantic support for C-family languages.
- Download the -win64 mingw-builds version of MinGW-w64. Extract the archive to
C:\MinGW64
and addC:\MinGW64\bin
to your PATH - Install Python 2.7 x86-64 for Windows to
C:\Python27
. - 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. - Compile LLVM with clang or download again from Haroogan. Click on proper number in download section to download LLVM. Unpack it to
C:\LLVM
- You need to have a 64-bit build of Vim for YCM to work. Haroogan has 64-bit builds that are confirmed working.
- Install CMake.
- Install:
git clone https://github.com/Valloric/YouCompleteMe .
git submodule update --init --recursive
- Replace file
%USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd\cpp\BoostParts\boost\detail\interlocked.hpp
with that file. - 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)
- Create a
build
directory andcd
into it. - 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 (originallymingw32-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"
- Run
mingw32-make ycm_support_libs
(Don't worry about the32
in that command) - (Obsolete) Copy
ycm_core.pyd
,ycm_client_support.pyd
, andlibclang.dll
from%USERPROFILE%\vimfiles\bundle\YouCompleteMe\third_party\ycmd
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.
- Check if you have YouCompleteMe and build directory on the same drive (in this guide
- if Vim :version indicates +python/dyn then Vim was compiled with Python2 support - that's good. but if Vim :echo has('python') returns 0 then you have the wrong memory model of Python2 installed - bad.
- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) - caused by %PATH% problems - and not necessarily with Python!
- step 12. make (90%) - Linking CXX shared library C:\Users\P\vimfiles\bundle\YouCompleteMe\third_party
ycmd\ycm_core.pyd - C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw3 2/bin/ld.exe: i386 architecture of input file `C:\Python27\libs\libpython27.a(du ks00143.o)' is incompatible with i386:x86-64 output... This is caused by forgetting to reinstall libpython27.a in step 3. after reinstalling Python 2.7 in step 2. - "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 inC:\Python27\libs
directory and repeat from step 11. Check if cmake foundlibpython27.a
.
- delete all files from build directory, check if
- during linking stage "..\BoostParts\libBoostParts.a(tss_dll.cpp.obj):tss_dll.cpp:(.text+0x70): multiple definition of `boost::tss_cleanup_implemented()'"
- comment out
namespace boost { void tss_cleanup_implemented() {} };
inycm_client_supprt.cpp and ycm_core.cpp
- comment out
- if you compiled LLVM on windows with mingw following the instructions at http://stackoverflow.com/questions/9427356/how-to-compile-clang-on-windows note that PATH_TO_LLVM_ROOT will actually need to point to the location of the clang folder under tools, not the top level LLVM folder
References:
[1] http://stackoverflow.com/a/21820642
[2] https://sourceforge.net/projects/cygwin-ports/
[3] https://github.com/Valloric/YouCompleteMe/issues/684
gcc --version == 4.9.X
- You can find this in the cygwin setup installer. Just downgrade gcc.
- If your cygwin only has
gcc >= 5.0
, this guide might work, but if it fails, try and compileclang > 3.7
, using an equivalent version ofcygwin-clang.patch
, listed in the next step.
- Download or copy the cygwin64 boost.python patch from this gist. Place this in
~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/
and name itcygwin64.BoostParts.patch
- Compile YCM as follows:
$ cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/
$ rm *.dll *.dll.a
$ mkdir -pv cpp/build && cd cpp/
$ patch -p2 < cygwin64.BoostParts.patch #fix boost for cygwin64. Might not be necessary in future YCM released
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make # replace with make -j <num-of-cores> for speed.
- To test that the ycm_core.dll does not cause any segfaults in python attempt the following:
$ cd ../../
$ python.exe # Load python prompt
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>> import ycm_core
- If there are no errors, exit python by typing
quit()
and hitting enter or hit Ctrl-D. - YCM should work fine in cygwin now! Make sure you've set up your global and per-project .ycm_extra_conf files!
Enjoy!
Disclaimer: This is what worked for me
Recent versions of cygclang.dll (>3.5) have made some runtime changes that result in python suffering a STATUS_ACCESS_VIOLATION when loading ycm_core.dll (in both 32-bit cygwin and 64-bit cygwin) when using the cygwin-provided development packages (as mentioned below).
Since there are no prepackaged builds of clang or llvm for cygwin that do not have this issue, and simply compiling clang leads to #include file search failures, I've written a guide on patching clang using the cygport project's llvm patches.
References:
[1] http://stackoverflow.com/a/21820642
[2] https://sourceforge.net/projects/cygwin-ports/
[3] https://github.com/Valloric/YouCompleteMe/issues/684
gcc --version == 4.9.X
- You can find this in the cygwin setup installer. Just downgrade gcc.
- If your cygwin only has
gcc >= 5.0
, this guide might work, but if it fails, try and compileclang > 3.7
, using an equivalent version ofcygwin-clang.patch
, listed in the next step.
- Download or copy the cygwin64 boost.python patch from this gist. Place this in
~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/
and name itcygwin64.BoostParts.patch
- Download 3.5.1-cygwin-clang.patch
- If your cygwin installation only provides
gcc >= 5
, get the patch for clang > 3.7 here
- Grab the
llvm-x.y.z
andclang-x.y.z
sources from the llvm website
- Untar these sources as follows:
$ LLVM_VERSION="x.y.z" # replace x.y.z with your version, such as 3.5.1
$ mkdir -pv ~/downloads/src/ && cd ~/downloads/src
$ mv <path-to-llvm-tarfile> . && mv <path-to-clang-tarfile> .
$ tar xvf llvm-${LLVM_VERSION}.src.tar.xz
$ cd llvm-${LLVM_VERSION}.src/tools/ && mkdir -pv clang && tar xvf ../../cfe-${LLVM_VERSION}.src.tar.xv -C clang --strip-components=1
$ cd ..
$ patch -p2 < ../${LLVM_VERSION}-cygwin-clang.patch #Patch clang for cygwin
$ unset LLVM_VERSION
- Compile
$ ./configure --enable-optimizations --disable-assertions --enable-shared # If the configure command complains about libffi, install libffi-devel ether through setup-x86_64.exe or apt-cyg and re-run it.
$ make && make install # you can also use make -j <number> && make -j <number> install, where <number> is the number of CPU cores you wish to use to compile.
- Check that
/usr/local/bin/cygclang.dll
exists. - Compile YCM as follows:
$ cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/
$ rm *.dll *.dll.a
$ mkdir -pv cpp/build && cd cpp/
$ patch -p2 < cygwin64.BoostParts.patch #fix boost for cygwin64. Might not be necessary in future YCM released
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_BOOST=OFF -DEXTERNAL_LIBCLANG_PATH=/usr/local/bin/cygclang.dll ..
$ make # replace with make -j <num-of-cores> for speed.
- To test that the ycm_core.dll does not cause any segfaults in python attempt the following:
$ cd ../../
$ python.exe # Load python prompt
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>> import ycm_core
- If there are no errors, exit python by typing
quit()
and hitting enter or hit Ctrl-D. - YCM should work fine in cygwin now! Make sure you've set up your global and per-project .ycm_extra_conf files!
Enjoy!