Difference between revisions of "CB Clangd Client"

From Code::Blocks
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The repository page of this plugin is: https://sourceforge.net/projects/cb-clangd-client/
+
The repository page of this plugin is: [https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/contrib/clangd_client https://sourceforge.net/projects/cb-clangd-client/]
  
 
It uses [https://clangd.llvm.org/ clangd] through [https://en.wikipedia.org/wiki/Language_Server_Protocol Language Server Protocol].
 
It uses [https://clangd.llvm.org/ clangd] through [https://en.wikipedia.org/wiki/Language_Server_Protocol Language Server Protocol].
Line 5: Line 5:
 
The related forum discussion is:  — [https://forums.codeblocks.org/index.php/topic,24357.html Code completion using LSP and clangd]
 
The related forum discussion is:  — [https://forums.codeblocks.org/index.php/topic,24357.html Code completion using LSP and clangd]
 
== '''What is Clangd'''==
 
== '''What is Clangd'''==
 +
clangd understands your C++ code and adds smart features to your editor
  
    clangd understands your C++ code and adds smart features to your editor:
+
* code completion
:::* code completion
+
* compile errors
:::* compile errors  
+
* go-to-definition
:::* go-to-definition  
+
* go-to-implementation
:::* go-to-implementation
+
* find references
:::* find references
 
:::  and more.
 
  
    clangd is a language server that can work with your editor via a plugin.
+
and more.
    CodeBlocks provides Clangd_client as the needed plugin.
 
  
    Clangd_client additionally enhances the clangd server by providing:
+
clangd is a language server that can work with your editor via a plugin.
 +
CodeBlocks provides Clangd_client as the needed plugin.
  
:::* call tips
+
Clangd_client additionally enhances the clangd server by providing:
:::* function definitions
 
:::* parameter definitions
 
:::* previous and next function positioning
 
:::* symbols browser
 
:::* go-to-file
 
:::* go-to-function
 
:::* symbol renaming
 
  
 +
* call tips
 +
* function definitions
 +
* parameter definitions
 +
* previous and next function positioning
 +
* symbols browser
 +
* go-to-file
 +
* go-to-function
 +
* symbol renaming
 +
 +
 +
 +
NOTE: A CodeBlocks '''project is required''' for Clangd_client.
 +
 +
Clangd_client does not work with non-project translation units.
 +
 +
A project provides the necessary resources to interface between the Editor and the Clangd server.
 
----
 
----
  
 
=='''Configuring clangd_client'''==
 
=='''Configuring clangd_client'''==
:: Clangd_client requires the third-party binary clangd executable.
+
Clangd_client requires the third-party binary clangd executable.
:: See '''Windows: Compiler Clangd/LLVM Package Installer''' below to install it.
+
 
:: or  '''Linux: Clangd executable install process'''
+
See '''Windows: Compiler Clangd/LLVM Package Installer''' below to install it.
  
:: After a success clangd executable install, perform the following:
+
or '''Linux: Clangd executable install process'''
:::Disable the "CodeCompletion" plugin.
 
::::* Navigate to Setting->Plugins->Manage Plugins and '''disable''' CodeCompletion.
 
::::* Navigate to Setting->Plugins->Manage Plugins and '''enable''' Clangd_client.
 
:::'''Restart Codeblocks'''.
 
  
:::Tell CodeBlocks (or verify) where the clangd executable resides:
+
After a successful clangd executable install, perform the following:<blockquote>Disable the "CodeCompletion" plugin.
::::* Navigate to Setting->Editor->Clangd_client->C/C++ parser(tab) and verify or enter the location of the cland executable in the box labeled "Specify clangd executable to use".
+
 
::<br />
+
* Navigate to Setting->Plugins->Manage Plugins and '''disable''' CodeCompletion.
 +
* Navigate to Setting->Plugins->Manage Plugins and '''enable''' Clangd_client.
 +
 
 +
'''Restart Codeblocks'''.
 +
 
 +
Tell CodeBlocks (or verify) where the clangd executable resides:
 +
 
 +
* Navigate to Setting->Editor->Clangd_client->C/C++ parser(tab) and verify or enter the location of the clangd executable in the box labeled "Specify clangd executable to use".
 +
</blockquote>
 
----
 
----
  
 
== '''Installing Clangd_client from source or pre-built binary ''' ==
 
== '''Installing Clangd_client from source or pre-built binary ''' ==
 +
Note: Clangd_client is now included as a contrib plugin within the "Nightly" builds.
  
#     Install the LLVM or Clangd.exe as documented in the section below entitled:
+
Using a "Nightly" build is the easiest way to update to clangd_client.
#: '''Windows Clangd executable install process'''
+
 
#::<br />
+
Simply install the "Nightly" and configure as specified below.
#    Disable the Code completion plugin as follows:
+
 
#:   a) Open the Plugin manager via  Code::Blocks menu  
+
See the Nightly builds at https://forums.codeblocks.org/index.php/board,20.0.html
 +
 
 +
# Install the LLVM or Clangd.exe as documented in the section below entitled:
 +
#:'''Windows Clangd executable install process'''
 +
# Disable the Code completion plugin as follows:
 +
#: a) Open the Plugin manager via  Code::Blocks menu  
 
#::        "MainMenu=>Plugins=>Manage plugins..."  
 
#::        "MainMenu=>Plugins=>Manage plugins..."  
#:   b) In the Manage Plugin dialog do the following:
+
#: b) In the Manage Plugin dialog do the following:
#::         i  ) Find and select the "Code completion" plugin via it's title  
+
#:: i  ) Find and select the "Code completion" plugin via it's title
 
#::          ii ) Press the "Disable" button on the right near the top
 
#::          ii ) Press the "Disable" button on the right near the top
 
#::          iii) If you get any errors please try again.
 
#::          iii) If you get any errors please try again.
#::<br />  
+
# Install the Clangd-Client Plugin using one of the following options, which are documented below:  
#    Install the Clangd-Client Plugin using one of the following options, which are documented below:  
+
#: a) Install via the Plugin Manager
#:     a) Install via the Plugin Manager
 
 
#:      b) Manually install the plugin files
 
#:      b) Manually install the plugin files
#:<br />
+
# Configure the Clangd-Client Plugin for use as follows:
#    Configure the Clangd-Client Plugin for use as follows:
+
#: a) Select the CodeBlocks menu item "Settings->Editor..."
#:     a) Select the CodeBlocks menu item "Settings->Editor..."
 
 
#:      b) In the list on the left click/select the "clangd_client" option.
 
#:      b) In the list on the left click/select the "clangd_client" option.
 
#:      c) In the "C/C++ parser" tab change the "Specify clangd executable to use" to reference the clangd.exe you installed via step 1) above.  
 
#:      c) In the "C/C++ parser" tab change the "Specify clangd executable to use" to reference the clangd.exe you installed via step 1) above.  
          Some examples of this could be:
+
#: Some examples of this could be:
              C:\msys64\clang64\bin\clangd.exe
+
#:* C:\msys64\clang64\bin\clangd.exe
              C:\msys64\clang32\bin\clangd.exe
+
#:* C:\msys64\clang32\bin\clangd.exe
              C:\LLVM\bin\clangd.exe
+
#:* C:\msys64\mingw64\bin\clangd.exe
              C:\comilers\clang\clangd.exe
+
#:* C:\msys64\mingw32\bin\clangd.exe
 
+
#:* C:\LLVM\bin\clangd.exe
 +
#:* C:\comilers\clang\clangd.exe
 
----
 
----
  
 
== '''Manually Remove Clangd-Client Plugin''' ==
 
== '''Manually Remove Clangd-Client Plugin''' ==
  
#   Exit Code::Blocks!
+
# Exit Code::Blocks!
#:<br />
+
# If you manually installed the files or used the Plugin manager then you can do the following:
If you manually installed the files or used the Plugin manager then you can do the following:
+
#: a) In the Code::Blocks '''...\share\CodeBlocks''' folder delete the clangd_client.zip file
#: a) In the Code::Blocks '''...\share\CodeBlocks''' folder delete the clangd_client.zip file
 
 
#:  b) In the Code::Blocks '''...\share\CodeBlocks\plugins''' folder delete the clangd_client.dll file
 
#:  b) In the Code::Blocks '''...\share\CodeBlocks\plugins''' folder delete the clangd_client.dll file
#:<br />
+
# If you installed via the Plugin manager then you can delete the files with the following commands:
#        If you installed via the Plugin manager then you can delete the files with the following commands:
+
#: a) del '''%APPDATA%\CodeBlocks\share\codeblocks\plugins\clangd_client.dll'''
#: a) del '''%APPDATA%\CodeBlocks\share\codeblocks\plugins\clangd_client.dll'''
 
 
#:  b) del '''%APPDATA%\CodeBlocks\share\codeblocks\clangd_client.zip'''
 
#:  b) del '''%APPDATA%\CodeBlocks\share\codeblocks\clangd_client.zip'''
#:<br />
+
# If you want to reuse older code completion remember to re-enable the plugin and restart CodeBlocks.
#    If you want to reuse older code completion remember to re-enable the plugin
 
#:<br />
 
 
----
 
----
  
 
== '''Windows: Clangd executable install process:''' ==
 
== '''Windows: Clangd executable install process:''' ==
 
+
There are three main options to install the clangd.exe:
::There are three main options to install the clangd.exe:
 
 
#        Install the LLVM compiler.
 
#        Install the LLVM compiler.
 
#        Manully extract the required files from the LLVM compiler.
 
#        Manully extract the required files from the LLVM compiler.
 
#        Install the Clangd package for the Windows compiler you are using if it is available.
 
#        Install the Clangd package for the Windows compiler you are using if it is available.
:<br />
+
The process for the three options above are detailed below.
::The process for the three options above are detailed below.
 
 
 
 
----
 
----
  
 
== '''Windows: Install the LLVM compiler''' ==
 
== '''Windows: Install the LLVM compiler''' ==
  
#   Download the latest (non RC/Beta) LLVM Windows executable for your OS (Win32 or Win64) from the following
+
# Download the latest (non RC/Beta) LLVM Windows executable for your OS (Win32 or Win64) from the following
#:       Github LLVM download page:
+
#: Github LLVM download page: https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8
#:      https://github.com/llvm/llvm-project/releases
+
#: As of Jan 2022 the Windows files are named as follows:
#:<br />
+
#:* LLVM-<version>-win64.exe
#:   As of Jan 2022 the Windows files are named as follows:
+
#:* LLVM-<version>-win32.exe
#:     LLVM-<version>-win64.exe
+
#: where <version> is the LLVM version, like 13.0.0 or 13.0.1.
#:     LLVM-<version>-win32.exe
 
#:   where <version> is the LLVM version, like 13.0.0 or 13.0.1.
 
#:<br />
 
 
#    Run the LLVM-<version>-win<xx>.exe you downloaded to install the LLVM compiler.
 
#    Run the LLVM-<version>-win<xx>.exe you downloaded to install the LLVM compiler.
  
----
 
 
== '''Windows: Manually Extract File from LLVM compiler''' ==
 
#    Download the latest (non RC/Beta) LLVM Windows executable for your OS (Win32 or Win64) from the following
 
#::      Github LLVM download page:
 
#::      https://github.com/llvm/llvm-project/releases
 
#::
 
#::  As of Jan 2022 the Windows files are names as follows:
 
#::      LLVM-<version>-win64.exe
 
#::      LLVM-<version>-win32.exe
 
#::  where <version> is the LLVM version, like 13.0.0 or 13.0.1.
 
#::
 
#    Unzip the LLVM-<version>-win<xx>.exe file you downloaded using 7zip or your prefered ZIP program into a sub directory
 
#    Create a new directory to put the clangd.exe and dll's
 
#    Copy the following files into a the new directory created from the unziped #::LLVM directory:
 
#::            bin\clangd.exe
 
#::            bin\msvcp140.dll
 
#::            bin\vcruntime140.dll
 
#::            bin\vcruntime140_1.dll
 
#::
 
 
----
 
----
  
 
== '''Windows: Compiler Clangd/LLVM Package Installer''' ==
 
== '''Windows: Compiler Clangd/LLVM Package Installer''' ==
    Due to the number of different compilers available for Windows not all of the compilers will have either/both the Clang or LLVM required files.
+
Due to the number of different compilers available for Windows not all of the compilers will have either/both the Clang or LLVM required files.
 
 
    If you want to install the specific package(s) for the Windows compiler you are using in order to use it's clangd.exe file please follow the instructions below for the specific compiler you have installed:
 
 
 
    '''MSYS2 Compiler - MinGW64'''
 
<pre>
 
      There are two main options to install the clangd.exe as follows:
 
      1) The first option in order to  minimise disk space is to install the Clang extra
 
          tools using one of the following packages:
 
  
          +------------------------------------------+------------------------+
+
If you want to install the specific package(s) for the Windows compiler you are using in order to use it's clangd.exe file please follow the instructions below for the specific compiler you have installed:
          |              Package                    | Clangd executable      |
 
          +------------------------------------------+------------------------+
 
          | mingw-w64-clang-x86_64-clang-tools-extra | clang64/bin/clangd.exe |
 
          | mingw-w64-x86_64-clang-tools-extra      | mingw64/bin/clangd.exe |
 
          +------------------------------------------+------------------------+
 
  
          To intall the package do the following:
+
'''MSYS2 Compiler - MinGW64'''
          a) Open the msys2.exe bash shell  
+
There are two main options to install the clangd.exe as follows:
          b) Run the following command:
+
1) The first option in order to  minimise disk space is to install the Clang extra
                  pacman -S <Package name in the table above>
+
tools using one of the following packages:
   
+
+------------------------------------------+------------------------+
      '''OR'''
+
<nowiki>|              Package                    |</nowiki> Clangd executable      |
 
+
+------------------------------------------+------------------------+
      2) The second option is to intall the full Clang tool chain as follows:
+
<nowiki>| mingw-w64-clang-x86_64-clang-tools-extra |</nowiki> clang64/bin/clangd.exe |
          a) Open the msys2.exe bash shell  
+
<nowiki>| mingw-w64-x86_64-clang-tools-extra      |</nowiki> mingw64/bin/clangd.exe |
          b) Run the following command:
+
<nowiki>| mingw-w64-ucrt-x86_64-clang-tools-extra  |</nowiki> ucrt64/bin/clangd.exe  |
                  pacman -S mingw-w64-clang-x86_64-toolchain
+
+------------------------------------------+------------------------+
</pre>
+
<nowiki> </nowiki>        To intall the package do the following:
    '''MSYS2 Compiler - MinGW32'''
+
<nowiki> </nowiki>          a) Open the msys2.exe bash shell  
 +
<nowiki> </nowiki>          b) Run the following command:
 +
<nowiki> </nowiki>                pacman -S <Package name in the table above>
 +
<nowiki> </nowiki>      <nowiki>'''</nowiki>OR<nowiki>'''</nowiki>
 +
<nowiki> </nowiki>      2) The second option is to intall the full Clang tool chain as follows:
 +
<nowiki> </nowiki>          a) Open the msys2.exe bash shell  
 +
<nowiki> </nowiki>          b) Run the following command:
 +
<nowiki> </nowiki>                pacman -S mingw-w64-clang-x86_64-toolchain
 +
'''MSYS2 Compiler - MinGW32'''
 
<pre>
 
<pre>
 
       There are two main options to install the clangd.exe as follows:
 
       There are two main options to install the clangd.exe as follows:
Line 192: Line 174:
 
           b) Run the following command:
 
           b) Run the following command:
 
                   pacman -S mingw-w64-clang-i686-toolchain
 
                   pacman -S mingw-w64-clang-i686-toolchain
</pre>
+
</pre>'''[https://forums.codeblocks.org/index.php/topic,24357.msg169412.html#msg169412 Notes from the CodeBlocks forum to avoid mixing incompatible gcc/clangd executables]'''
  
-------------------------------------------------------------------------------------
+
'''Don't mix mingw64 with clang64'''.
'''Notes from the CodeBlocks forum to avoid mixing incompatible gcc/clangd executables.'''
 
-------------------------------------------------------------------------------------
 
    https://forums.codeblocks.org/index.php/topic,24357.msg169412.html#msg169412
 
  
::: '''Don't mix mingw64 with clang64'''.
+
If you are using the gcc from msys2, (the compilers in the folder '''msys64\mingw64\bin'''), you should use "mingw-w64-x86_64-clang-tools-extra", (the clangd.exe is under the folder '''msys64\mingw64\bin''') the same folder as your gcc.exe. If you are using the clang tool chain, (the folder '''msys64\clang64\bin'''), you should use "mingw-w64-clang-x86_64-clang-tools-extra". I found that I just make a big mistake. That is: I used the gcc toolchain from '''msys64\mingw64\bin''', but I used the clangd.exe from '''msys64\clang64\bin'''. The result is I got a lot of LSP diagnostics messages and errors. Luckily I found the reason, and fixed this issue. Hope this will help others.
  
:: If you are using the gcc from msys2, (the compilers in the folder '''msys64\mingw64\bin'''),
+
'''A note from eckard_klotz:'''
:: you should use "mingw-w64-x86_64-clang-tools-extra",
 
:: (the clangd.exe is under the folder '''msys64\mingw64\bin''') the same folder as your gcc.exe.
 
::<br />
 
:: If you are using the clang tool chain, (the folder '''msys64\clang64\bin'''),
 
:: you should use "mingw-w64-clang-x86_64-clang-tools-extra".
 
  
:: I found that I just make a big mistake. That is: I used the gcc toolchain from
+
I faced the same issue. But I'm using the build-suite under in the folder "msys64\'''ucrt64'''\bin" and thus, I had to install package '''mingw-w64-ucrt-x86_64-clang-tools-extra''' for adding the clangd tool to my compiler-suite.
:: '''msys64\mingw64\bin''', but I used the clangd.exe from '''msys64\clang64\bin'''.
 
:: The result is I got a lot of LSP diagnostics messages and errors.
 
:: Luckily I found the reason, and fixed this issue. Hope this will help others.
 
::<br />
 
 
-----
 
-----
 
== '''Linux: Clangd executable install process:''' ==
 
== '''Linux: Clangd executable install process:''' ==
::
+
NOTE: Clangd_client plugin requires a clangd executable version 13 or greater.
::NOTE: Clangd_client plugin requires a cland executable version 13 or greater.
+
 
::Check your current clangd version by running '''clangd --version'''
+
Check your current clangd version by running '''clangd --version'''
::If the version is less than 13 you will have to install a newer version.
+
 
:::See https://clangd.llvm.org/installation.html
+
If the version is less than 13 you will have to install a newer version.
::<br />
+
 
::Installing the clangd package will usually give you a slightly older version.
+
See https://clangd.llvm.org/installation.html<blockquote>Installing the clangd package will usually give you a slightly older version.
::Test this by issuing '''apt-get install --dry-run clangd'''
+
 
::As of 2022/11/16, this suggest that cland version 10 will be installed.
+
Test this by issuing '''apt-get install --dry-run clangd'''
::If the clangd version shows less than version 13, you'll have to install a specific version as follows:
+
 
::<br />
+
As of 2022/11/16, this suggest that clangd version 10 will be installed.</blockquote>If the clangd version shows less than version 13, you'll have to install a specific version as follows:<blockquote>Install a packaged release (''must be version 13 or greater''):
::Install a packaged release (''must be version 13 or greater''):
+
 
::::'''sudo apt-get install clangd-13''' ''(Must be version 13 or greater)''.
+
'''sudo apt-get install clangd-13''' ''(Must be version 13 or greater)''.</blockquote>This will install clangd as '''/usr/bin/clangd-13'''.
 +
 
 +
You can now configure clangd_client plugin by following the above instructions at
 +
 
 +
[https://wiki.codeblocks.org/index.php/CB_Clangd_Client#Configuring_clangd_client] '''Configuring clangd_client'''
  
::This will install clangd as '''/usr/bin/clangd-13'''.
+
If you prefer to install the entire LLVM/Clang package, for convenience, there is an automatic installation script available that installs LLVM for you.
::<br />
 
:: You can now configure clangd_client plugin by following the above instructions at
 
:::: [https://wiki.codeblocks.org/index.php/CB_Clangd_Client#Configuring_clangd_client] '''Configuring clangd_client'''
 
  
::<br />
+
To install the latest stable version: see [https://apt.llvm.org/] '''Automatic installation script'''.
:: If you prefer to install the entire LLVM/Clang package, for convenience, there is
 
:: an automatic installation script available that installs LLVM for you.
 
:: To install the latest stable version: see [https://apt.llvm.org/] '''Automatic installation script'''.
 
:: Note that you can specify the version number with this script.
 
  
 +
Note that you can specify the version number with this script.
 
----
 
----

Latest revision as of 18:02, 15 November 2024

The repository page of this plugin is: https://sourceforge.net/projects/cb-clangd-client/

It uses clangd through Language Server Protocol.

The related forum discussion is: — Code completion using LSP and clangd

What is Clangd

clangd understands your C++ code and adds smart features to your editor

  • code completion
  • compile errors
  • go-to-definition
  • go-to-implementation
  • find references

and more.

clangd is a language server that can work with your editor via a plugin. CodeBlocks provides Clangd_client as the needed plugin.

Clangd_client additionally enhances the clangd server by providing:

  • call tips
  • function definitions
  • parameter definitions
  • previous and next function positioning
  • symbols browser
  • go-to-file
  • go-to-function
  • symbol renaming


NOTE: A CodeBlocks project is required for Clangd_client.

Clangd_client does not work with non-project translation units.

A project provides the necessary resources to interface between the Editor and the Clangd server.


Configuring clangd_client

Clangd_client requires the third-party binary clangd executable.

See Windows: Compiler Clangd/LLVM Package Installer below to install it.

or Linux: Clangd executable install process

After a successful clangd executable install, perform the following:

Disable the "CodeCompletion" plugin.

  • Navigate to Setting->Plugins->Manage Plugins and disable CodeCompletion.
  • Navigate to Setting->Plugins->Manage Plugins and enable Clangd_client.

Restart Codeblocks.

Tell CodeBlocks (or verify) where the clangd executable resides:

  • Navigate to Setting->Editor->Clangd_client->C/C++ parser(tab) and verify or enter the location of the clangd executable in the box labeled "Specify clangd executable to use".

Installing Clangd_client from source or pre-built binary

Note: Clangd_client is now included as a contrib plugin within the "Nightly" builds.

Using a "Nightly" build is the easiest way to update to clangd_client.

Simply install the "Nightly" and configure as specified below.

See the Nightly builds at https://forums.codeblocks.org/index.php/board,20.0.html

  1. Install the LLVM or Clangd.exe as documented in the section below entitled:
    Windows Clangd executable install process
  2. Disable the Code completion plugin as follows:
    a) Open the Plugin manager via Code::Blocks menu
    "MainMenu=>Plugins=>Manage plugins..."
    b) In the Manage Plugin dialog do the following:
    i ) Find and select the "Code completion" plugin via it's title
    ii ) Press the "Disable" button on the right near the top
    iii) If you get any errors please try again.
  3. Install the Clangd-Client Plugin using one of the following options, which are documented below:
    a) Install via the Plugin Manager
    b) Manually install the plugin files
  4. Configure the Clangd-Client Plugin for use as follows:
    a) Select the CodeBlocks menu item "Settings->Editor..."
    b) In the list on the left click/select the "clangd_client" option.
    c) In the "C/C++ parser" tab change the "Specify clangd executable to use" to reference the clangd.exe you installed via step 1) above.
    Some examples of this could be:
    • C:\msys64\clang64\bin\clangd.exe
    • C:\msys64\clang32\bin\clangd.exe
    • C:\msys64\mingw64\bin\clangd.exe
    • C:\msys64\mingw32\bin\clangd.exe
    • C:\LLVM\bin\clangd.exe
    • C:\comilers\clang\clangd.exe

Manually Remove Clangd-Client Plugin

  1. Exit Code::Blocks!
  2. If you manually installed the files or used the Plugin manager then you can do the following:
    a) In the Code::Blocks ...\share\CodeBlocks folder delete the clangd_client.zip file
    b) In the Code::Blocks ...\share\CodeBlocks\plugins folder delete the clangd_client.dll file
  3. If you installed via the Plugin manager then you can delete the files with the following commands:
    a) del %APPDATA%\CodeBlocks\share\codeblocks\plugins\clangd_client.dll
    b) del %APPDATA%\CodeBlocks\share\codeblocks\clangd_client.zip
  4. If you want to reuse older code completion remember to re-enable the plugin and restart CodeBlocks.

Windows: Clangd executable install process:

There are three main options to install the clangd.exe:

  1. Install the LLVM compiler.
  2. Manully extract the required files from the LLVM compiler.
  3. Install the Clangd package for the Windows compiler you are using if it is available.

The process for the three options above are detailed below.


Windows: Install the LLVM compiler

  1. Download the latest (non RC/Beta) LLVM Windows executable for your OS (Win32 or Win64) from the following
    Github LLVM download page: https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8
    As of Jan 2022 the Windows files are named as follows:
    • LLVM-<version>-win64.exe
    • LLVM-<version>-win32.exe
    where <version> is the LLVM version, like 13.0.0 or 13.0.1.
  2. Run the LLVM-<version>-win<xx>.exe you downloaded to install the LLVM compiler.

Windows: Compiler Clangd/LLVM Package Installer

Due to the number of different compilers available for Windows not all of the compilers will have either/both the Clang or LLVM required files.

If you want to install the specific package(s) for the Windows compiler you are using in order to use it's clangd.exe file please follow the instructions below for the specific compiler you have installed:

MSYS2 Compiler - MinGW64

There are two main options to install the clangd.exe as follows:
1) The first option in order to  minimise disk space is to install the Clang extra 
tools using one of the following packages:
+------------------------------------------+------------------------+
|               Package                    | Clangd executable      |
+------------------------------------------+------------------------+
| mingw-w64-clang-x86_64-clang-tools-extra | clang64/bin/clangd.exe |
| mingw-w64-x86_64-clang-tools-extra       | mingw64/bin/clangd.exe |
| mingw-w64-ucrt-x86_64-clang-tools-extra  | ucrt64/bin/clangd.exe  |
+------------------------------------------+------------------------+
          To intall the package do the following:
           a) Open the msys2.exe bash shell 
           b) Run the following command:
                  pacman -S <Package name in the table above>
       '''OR'''
       2) The second option is to intall the full Clang tool chain as follows:
           a) Open the msys2.exe bash shell 
           b) Run the following command:
                  pacman -S mingw-w64-clang-x86_64-toolchain

MSYS2 Compiler - MinGW32

       There are two main options to install the clangd.exe as follows:

       1) The first option in order to  minimise disk space is to install the Clang extra 
          tools using one of the following packages:

           +------------------------------------------+------------------------+
           |               Package                    | Clangd executable      |
           +------------------------------------------+------------------------+
           | mingw-w64-clang-i686-clang-tools-extra   | clang32/bin/clangd.exe |
           | mingw-w64-i686-clang-tools-extra         | mingw32/bin/clangd.exe |
           +------------------------------------------+------------------------+

          To intall the package do the following:
            a) Open the msys2.exe bash shell 
            b) Run the following command:
                  pacman -S <Package name in the table above>

        '''OR'''

       2) The second option is to install the full Clang tool chain as follows:
          a) Open the msys2.exe bash shell 
          b) Run the following command:
                  pacman -S mingw-w64-clang-i686-toolchain

Notes from the CodeBlocks forum to avoid mixing incompatible gcc/clangd executables

Don't mix mingw64 with clang64.

If you are using the gcc from msys2, (the compilers in the folder msys64\mingw64\bin), you should use "mingw-w64-x86_64-clang-tools-extra", (the clangd.exe is under the folder msys64\mingw64\bin) the same folder as your gcc.exe. If you are using the clang tool chain, (the folder msys64\clang64\bin), you should use "mingw-w64-clang-x86_64-clang-tools-extra". I found that I just make a big mistake. That is: I used the gcc toolchain from msys64\mingw64\bin, but I used the clangd.exe from msys64\clang64\bin. The result is I got a lot of LSP diagnostics messages and errors. Luckily I found the reason, and fixed this issue. Hope this will help others.

A note from eckard_klotz:

I faced the same issue. But I'm using the build-suite under in the folder "msys64\ucrt64\bin" and thus, I had to install package mingw-w64-ucrt-x86_64-clang-tools-extra for adding the clangd tool to my compiler-suite.


Linux: Clangd executable install process:

NOTE: Clangd_client plugin requires a clangd executable version 13 or greater.

Check your current clangd version by running clangd --version

If the version is less than 13 you will have to install a newer version.

See https://clangd.llvm.org/installation.html

Installing the clangd package will usually give you a slightly older version.

Test this by issuing apt-get install --dry-run clangd

As of 2022/11/16, this suggest that clangd version 10 will be installed.

If the clangd version shows less than version 13, you'll have to install a specific version as follows:

Install a packaged release (must be version 13 or greater): sudo apt-get install clangd-13 (Must be version 13 or greater).

This will install clangd as /usr/bin/clangd-13.

You can now configure clangd_client plugin by following the above instructions at

[1] Configuring clangd_client

If you prefer to install the entire LLVM/Clang package, for convenience, there is an automatic installation script available that installs LLVM for you.

To install the latest stable version: see [2] Automatic installation script.

Note that you can specify the version number with this script.