Reputation: 351
I have tried many different configuration options, I've built llvm/clang with windows and with mingw-64, but no matter what I set I am always stopped here. Since there isn't official support, the only help is the wiki documentation that hasn't been updated in a long time.
Has anyone gotten this to work?
C:\mingw64\bin\g++.exe -shared -o C:\Users\Daddy007\vimfiles\bundle\YouCompl
eteMe\third_party\ycmd\ycm_core.pyd -Wl,--out-implib,libycm_core.dll.a -Wl,--maj
or-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\ycm_co
re.dir/objects.a -Wl,--no-whole-archive ..\BoostParts\libBoostParts.a C:\Python2
7\libs\libpython27.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -l
oleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles\ycm_core.dir/objects.a(ClangCompleter.cpp.obj):ClangCompleter.cpp:(.t
ext+0x328): undefined reference to `clang_createIndex'
CMakeFiles\ycm_core.dir/objects.a(ClangCompleter.cpp.obj):ClangCompleter.cpp:(.t
ext+0x353): undefined reference to `clang_toggleCrashRecovery'
CMakeFiles\ycm_core.dir/objects.a(ClangCompleter.cpp.obj):ClangCompleter.cpp:(.t
ext+0x3ea): undefined reference to `clang_disposeIndex'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw3
2/bin/ld.exe: CMakeFiles\ycm_core.dir/objects.a(ClangCompleter.cpp.obj): bad rel
oc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
Upvotes: 0
Views: 2187
Reputation: 54
Steps that worked for me were the following. Make sure you use either 32-bit or 64-bit for all the steps, but never mix them. In the instructions there will be some paths, that depend on your installation. Make sure you adapt them and not just try to copy paste.
Get GVim (built against Python, you can check this in the version. There has to be an entry +python/dyn)
(For always up to date builds, I can recommend: https://tuxproject.de/projects/vim/)
Get the mingw-w64 toolchain.
Because of your question I am not exactly sure what version you got, but mingw-w64 is in my point of view one of the better toolchains available.
Online installer available here (mingw-w64-install.exe
):
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/
My versions used during building YCM:
(Once you launch the installer you will see what these names mean.)
x86_64-5.2.0-posix-seh-rt_v4-rev0
x86_64-5.3.0-posix-seh-rt_v4-rev0
Get cmake:
https://cmake.org/
Get Python 2.7.x
https://www.python.org/downloads/
The best would be to take 2.7.10, because 2.7.11 works but needs a fix in the registry because of https://bugs.python.org/issue25824
As you already compiled LLVM/Clang you may skip this step. If you use above mentioned toolchain, rebuild it. (This is required to get libclang.dll for semantic support.)
Get LLVM/Clang sources:
http://llvm.org/docs/GettingStarted.html
(had to define M_PI
in llvm\lib\Target\AMDGPU\SIISelLowering.cpp
, everything else pretty straight forward)
Get YouCompleteMe sources
git clone https://github.com/Valloric/YouCompleteMe
cd YouCompleteme
git submodule update --init --recursive
Generate libpython27.a
C:\Python27\libs\libpython27.a
was missing, so I had to create this. If you have it, you may still want to create this just to be sure.
In your toolchain's ...\mingw-w64\x86_64-5.2.0-posix-seh-rt_v4-rev0\mingw64\bin
folder there should be gendef and dlltool.
Go to your python27.dll and run (from command line):
gendef python27.dll
dlltool --dllname python27.dll --def python27.def --output-lib libpython27.a
Make sure ...\mingw-w64\x86_64-5.2.0-posix-seh-rt_v4-rev0\mingw64\bin
is added to PATH
environment variable, to save you some hassle.
Launch cmake-gui and configure
Generator will be: MinGW Makefiles
Where is the source code: .../YouCompleteMe/third_party/ycmd/cpp
Where to build the binaries: .../build
Uncheck BUILD_SHARED_LIBS
CMAKE_BUILD_TYPE: Release
Make sure every path concerning the toolchain is correct. (Paths to ld.exe, g++.exe, mingw32-make, objcopy, ...)
Where to put the built files:
CMAKE_INSTALL_PREFIX
: wherever you want, you will not find the necessary files there :).
The next variables depend on your installation of Clang.
EXTERNAL_LIBCLANG_PATH
: point to the libclang.dll
you built earlier with the same toolchain
(.../mingw-w64/x86_64-5.2.0-posix-seh-rt_v4-rev0/mingw64/bin/libclang.dll)
PATH_TO_LLVM_ROOT
: .../mingw-w64/x86_64-5.2.0-posix-seh-rt_v4-rev0/mingw64
PYTHON_EXECUTABLE: C:/python27/python.exe
PYTHON_INCLUDE_DIR: C:/python27/include
PYTHON_LIBRARY: C:/python27/libs/libpython27.a (the one you created earlier)
Check USE_CLANG_COMPLETER
(for semantic support)
Press Configure and Generate.
Now you should find the Makefile in the path specified at the top of cmake. (Where to build the binaries:)
Build YCM
Open command line and navigate to the directory and enter mingw32-make
.
The build will most likely fail before hitting 100%, the only thing you need is to get around 90%. I think it tried to compile the tests too and failed.
If you navigate to ...\YouCompleteMe\third_party\ycmd there should be the following files
ycm_core.pyd
ycm_client_support.pyd
libclang.dll
If they are there, lucky you.
You can now copy the folders in ...\YouCompleteMe\*
to the gvim folder, to check if it works.
In your _vimrc you can specify:
let g:ycm_path_to_python_interpreter = 'C:\python27\python.exe'
To point YCM to the right interpreter, if you have more then one installation (3.5) it may will produce problems, depending on which one is on the PATH.
Well this is about it, there are quite some steps where something can go wrong, or I may have missed something. If you face difficulties, just ask I may can help.
Just a side note. I can also recommend to build with Visual Studio 2015, a snapshot build from LLVM/Clang from http://llvm.org/builds/ and Python 2.7.11. Because VS 2015 supports Clang and is compatible with VS2015's VC++ (http://clang.llvm.org/docs/MSVCCompatibility.html).
Works well too.
Upvotes: 1