cjc Usage

cjc is a compilation command of the Cangjie programming language. It provides various functions and compilation options. This section describes how to use cjc.

The cjc-frontend (Cangjie frontend compiler) is provided together with the cjc through the Cangjie SDK. The cjc-frontend can compile the Cangjie source code to the Cangjie intermediate representation (LLVM IR). The cjc-frontend performs only frontend compilation of the Cangjie code. Although the cjc-frontend and cjc share some compilation options, the compilation process stops when the frontend compilation is complete. When cjc is used, the Cangjie compiler automatically performs frontend and backend compilation and linking. cjc-frontend is provided only as an entity of the frontend compiler. It is advised to use cjc for compiling Cangjie code, unless you are a compiler developer.

Note:

When cjc compilation is performed on macOS M1, the cjc compilation performance may fluctuate due to variations in CPU usage. Restarting the computer or stopping the task for a period of time may alleviate the issue, though there is currently no complete solution.

Basic cjc Usage

This section describes how to use cjc. For details about the compilation options, see cjc Compilation Options.

The method of using cjc is as follows:

cjc [option] file...

Assume that there is a Cangjie file named hello.cj.

main() {
    println("Hello, World!")
}

You can compile the file by running the following command:

$ cjc hello.cj

The executable file main is added to the working directory. By default, the cjc compiles the specified source code file into an executable file and names the executable file main.

The preceding is the default behavior of cjc when no compilation option is provided. You can use compilation options to control the behavior of cjc, for example, enable cjc to compile the entire package or specify the name of the output file.