Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to build CCLS on Linux (performed on Fedora)?

I have tried using CMake to build ccls many times and I have just about given so if anyone has a way to do it that would be mega helpful.

I am on Fedora Linux and I am using the repo to get ccls as the prebuilt binaries don’t work.

Any help would be appreciated. Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To get it to work on Fedora (I don’t see any reason why it shouldn’t work on other Linux distros) this is how I did it step by step:

Quick note: You may want to use sudo yum install clang-devel and sudo yum install llvm-devel since they potentially hold needed dependencies. Also make sure you have downloaded the other things you will need as instructed on the ccls wiki.

  1. Firstly I used git clone --depth=1 --recursive https://github.com/MaskRay/ccls to clone the repo into a folder.

  2. Secondly I went into the ccls folder and used cmake .. Which built the required things.

  3. Thirdly I the used the make command to fully build the repo and generate the ccls executable.

  4. Then I created a bin directory in the home directory and moved the ccls executable into it.

  5. Then I went into the .bashrc to add ccls to the system path and added the line export PATH="/home/$USER/bin:$PATH" to the final line of the bashrc. Then exited the file and used source ~/.bashrc to force a reset

  6. Finally I added the ccls language server settings to the coc config:

{
  "languageserver": {
    "ccls": {
      "command": "ccls",
      "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
      "rootPatterns": [".ccls-root", "compile_commands.json"],
      "initializationOptions": {
        "cache": {
          "directory": ".ccls-cache"
        },
        "client": {
          "snippetSupport": true
        }
      }
    }
  }
}

Alternatively you can (if you are using coc) use CocInstall coc-clangd in vim or nvim, which is a way you can get something similar to ccls for programming.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading