Versions/v1.0.5/English

`cjc` Usage

Sections2
On This Page2
API Symbols0

`cjc` Usage

cjc is the compilation command for the Cangjie programming language, offering extensive functionality and corresponding compilation options. This chapter introduces its basic usage.cjc-frontend (Cangjie Frontend Compiler) is provided alongside cjc through the Cangjie SDK. cjc-frontend can compile Cangjie source code into Cangjie's intermediate representation (LLVM IR). cjc-frontend only performs frontend compilation of Cangjie code. Although cjc-frontend and cjc share some compilation options, the compilation process terminates after frontend compilation. When using cjc, the Cangjie compiler automatically handles frontend and backend compilation as well as linking. cjc-frontend is provided solely as the physical embodiment of the frontend compiler. Except for compiler developers, cjc should be prioritized for compiling Cangjie code.

Basic Usage of `cjc`

This section introduces the basic usage of cjc. For details on compilation options, please refer to the cjc Compilation Options chapter.

The usage of cjc is as follows:

Suppose there is a Cangjie file named hello.cj:

You can compile this file using the following command:

An executable file named main will be generated in the working directory. By default, cjc compiles the given source code file into an executable and names it main.

The above describes cjc's default behavior when no compilation options are provided. You can control cjc's behavior using compilation options, such as instructing cjc to perform whole-package compilation or specifying the output file name.

shell
cjc [option] file...
cangjie
main() {
    println("Hello, World!")
}
shell
$ cjc hello.cj