Installing cldk
#
CLDK
is a Python SDK hosted on PyPI and can be installed using your preferred Python package manager.
Installation#
The Python SDK can be installed directly from PyPI using any Python package manager such as pip, poetry, or uv:
Programming Language Specific Dependencies#
CLDK
supports program analysis for multiple languages and requires additional dependencies to support specific languages. The following table lists the additional dependencies required for each language:
For Python analysis as well as to use the CLDK Python SDK, you will need to install the Python programming language with version 3.11 or later. We recommend using a package manager like pyenv to install and manage Python dependencies.
For Java analysis, CLDK relies on a companion project called codeanalyzer
. codeanalyzer
is a java project and you will therefore need to install the Java Development Kit (JDK) with java version 11 or later.
You can use a package manager like SDKMAN to install the JDK. First, install SDKMAN by running the following command:
-
To install
SDKMan
, open your terminal and enter the following command and follow the instructions to complete the installation: -
Open a new terminal or source the SDKMan! scripts:
Next, install java 11 or later using SDKMAN:
-
You can list all available java versions with:
You should see something like this:
-
Install Java 11 or above (we'll go with
11.0.25-sem
): -
Set Java 11 as the current (or default) Java version:
-
Verify the installation:
This should output the version of the installed Java.
openjdk 11.0.25 2024-10-15 IBM Semeru Runtime Open Edition 11.0.25.0 (build 11.0.25+9) Eclipse OpenJ9 VM 11.0.25.0 (build openj9-0.48.0, JRE 11 Linux amd64-64-Bit Compressed References 20241107_1233 (JIT enabled, AOT enabled) OpenJ9 - 1d5831436e OMR - d10a4d553 JCL - edded3f65c based on jdk-11.0.25+9)
Finally, to enable building Java projects automatically, you will need to install the maven
build tool. You can install maven
using a package manager like SDKMAN
:
-
Install Maven:
-
Make sure
Then, source the file to apply the changes:mvn
command is available in thePATH
. Ifmvn
is not in your path, add the following to your~/.zshrc
,~/.bashrc
or~/.bash_profile
file: -
Verify the installation:
This should output the version of the installed Maven.
CLDK uses LLVM and Clang Python bindings to analyze C/C++ code. The project requires specific versions:
- libclang >= 18.1.1
- clang >= 17.0.6
You can install LLVM and Clang using various package managers depending on your operating system.
-
Install LLVM 18 using Homebrew
-
Add LLVM to your PATH (add this to your ~/.zshrc or ~/.bash_profile)
-
Verify installation
This should output the version of the installed LLVM and Clang.
-
Add LLVM repository and install required packages
-
Create symlinks (optional but recommended)
-
Verify installation
This should output the version of the installed LLVM and Clang.
-
Install LLVM 18 and development packages
-
Create symlinks (optional but recommended)
-
Verify installation
This should output the version of the installed LLVM and Clang.
Additional Development Tools#
Some operating systems may require additional development tools:
-
Make sure you have the Xcode Command Line Tools installed. You can install them using the following command:
-
Additionally, you may need to install the following packages using Homebrew:
-
Install the required development tools using the following command:
Supported Python Versions#
CLDK
is compatible with Python versions 3.11 and later. The following table lists the supported Python versions and the corresponding CLDK
versions:
Python Version |
Compatible cldk Versions |
---|---|
3.11 | ≥0.4.0 |