Installing the Cangjie Toolchain
One of the essential tools used in developing a Cangjie program is the Cangjie compiler, which can compile the Cangjie source code into an executable binary file. The auxiliary tools of this modern programming language offer far beyond this. Cangjie provides developers with a comprehensive development toolchain, including the compiler, debugger, package manager, static checking tool, formatting tool, and coverage measurement tool. It also offers user-friendly installation and usage modes, with functions available right out of the box.
Currently, the Cangjie toolchain has been adapted to some Linux and Windows versions. However, a complete function test has been performed only on some Linux distributions. For details, see Installation and Support of the Tool Chain for Linux. The function integrity of the Cangjie toolchain is not guaranteed on platforms that have not been fully tested. In addition, the Cangjie compiler on Windows is implemented based on MinGW. This indicates that some functions may be unavailable compared to those on Linux. For details about the differences, see the release notes of the corresponding version.
Linux
Environment Setup
The environment requirements for installing the Cangjie toolchain on Linux are as follows:
Architecture | Environment Requirements |
---|---|
x86_64 | glibc 2.22, Linux Kernel 4.12 or later, and libstdc++ 6.0.24 or later |
aarch64 | glibc 2.27, Linux Kernel 4.15 or later, and libstdc++ 6.0.24 or later |
In addition, you need to install the following dependencies for Ubuntu 18.04:
$ apt-get install binutils libc-dev libc++-dev libgcc-7-dev
For details about the dependency installation commands of Linux distributions, see Installation and Support of the Tool Chain for Linux in the appendix.
The Cangjie toolchain also depends on the OpenSSL 3 component, which may fail to be installed from the default software sources of the preceding distributions and require manual installation. For details, see Installation and Support of the Tool Chain for Linux.
Installation Guide
Go to the official release channel of Cangjie and download the installation package that adapts to your platform architecture.
Cangjie-x.y.z-linux_x64.tar.gz
: Cangjie toolchain for x86_64 LinuxCangjie-x.y.z-linux_aarch64.tar.gz
: Cangjie toolchain for AArch64 Linux
Assume that Cangjie-x.y.z-linux_x64.tar.gz
is selected. After downloading the package to the local PC, decompress it.
tar xvf Cangjie-x.y.z-linux_x64.tar.gz
After the decompression is complete, the cangjie
directory that stores all contents of the Cangjie toolchain is displayed in the working directory. Install and configure the toolchain.
source cangjie/envsetup.sh
Check whether the installation is successful.
cjc -v
cjc
is the executable file name of the Cangjie compiler. If the compiler version is returned in the command output, the Cangjie toolchain has been successfully installed. It is worth noting that the envsetup.sh
script configures the environment variables related to the toolchain only in the current shell environment. Therefore, the Cangjie toolchain is available only in the shell environment. If you open a new shell environment, run the envsetup.sh
script again to configure the environment.
To make the environment variable configuration of the Cangjie toolchain automatically take effect during shell
startup, add the following command to the end of the shell
initialization configuration file such as $HOME/.bashrc
or $HOME/.zshrc
, depending on the shell
type:
# Assume that the Cangjie installation package is extracted to /home/user/cangjie.
source /home/user/cangjie/envsetup.sh # Absolute path of the envsetup.sh file
After the configuration is complete, the Cangjie compilation toolchain will be ready for use when the shell starts.
Uninstallation and Update
To uninstall the Cangjie toolchain, delete the installation package directory of the Cangjie toolchain and remove the preceding environment variables on Linux. A simple solution is to open a new shell environment.
$ rm -rf <path>/<to>/cangjie
To update the Cangjie toolchain, uninstall the current version and then install the latest Cangjie toolchain according to the preceding instructions.
Windows
This section describes how to install the Cangjie toolchain on Windows 10.
Installation Guide
For Windows, Cnagjie provide developers with installation packages in EXE
and ZIP
formats. Go to the official release channel of Cangjie and download the Windows installation package that adapts to your platform architecture.
If you select an installation package in EXE
format (for example, Cangjie-x.y.z-windows_x64.exe
), execute the file, and follow the installation wizard to complete the installation.
If you select an installation package in ZIP
format (for example, Cangjie-x.y.z-windows_x64.zip
), decompress it to an appropriate directory. In the installation package, there are three installation scripts in different formats: envsetup.bat
, envsetup.ps1
, and envsetup.sh
. Select one of them based on your preferences and environment configurations.
If Windows Command Prompt (CMD) is deployed, run the following command:
path\to\cangjie\envsetup.bat
If PowerShell is deployed, run the following command:
. path\to\cangjie\envsetup.ps1
If the MSYS shell or Bash is deployed, run the following command:
source path/to/cangjie/envsetup.sh
To check whether the installation is successful, run the cjc -v
command in the corresponding environment. If the Cangjie compiler version is output, the Cangjie toolchain has been successfully installed.
Note:
The installation of the
ZIP
installation package and execution script is similar to that on Linux. The environment variables configured by theenvsetup
script are valid only in the current CLI. If you open a new CLI, run theenvsetup
script again to configure the environment.
Uninstallation and Update
Run the executable unins000.exe
file in the Cangjie installation directory and follow the uninstallation wizard to complete the uninstallation.
To update the Cangjie toolchain, uninstall the current version and then install the latest Cangjie toolchain according to the preceding instructions.