Home > Back-end >  How to build CCLS on Linux (performed on Fedora)?
How to build CCLS on Linux (performed on Fedora)?

Time:04-10

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.

CodePudding user response:

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.

  • Related