A conscise guide to building ccls on Windows with MSVC

ccls is an awsome LSP implementation on C/C++/OC written by MaskRay. It also has a plugin on VSCode, providing intellisense on these languages. In this post I’m demonstrating a simple approach to configure and build ccls with MSVC on Windows.

Build LLVM & Clang first

First, you need to ensure you have a LLVM+Clang installation with required AST-related headers. In MaskRay/ccls/src/indexer.cc, we have

Unfortunately, this is not the case for the official installers.

The Windows prebuilt binaries lack C++ header files, thus they cannot be used.

So you will need to build LLVM+Clang locally with Visual Studio.

Then build ccls

Now that you already have CMake installed (Yes I’m sure you have), we can come back to the topic. This is what I did to prepare the repository

Then open cmake-gui, fill in the necessary information, click “Configure”. The default values look good to me.

If your LLVM is placed in the default directory (C:\Program Files\LLVM), the script should be able to find it. Otherwise, you need to click “Add Entry” and specify your LLVM path in CMAKE_PREFIX_PATH BEFORE clicking “Configure” button.

Click “Generate” to generate the Visual Studio Solution for ccls. Then “Open Project”.

You know what to do next. Choose a configuration (Debug / RelWithDebInfo), then build ccls. This should be enough. You will find ccls.exe in your target folder.

Then you can use it to power your ccls plugin in VSCode.

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Content is available under CC BY-SA 3.0 unless otherwise noted.