Compiling and Running with cjc
cjc is the compiler for the Cangjie language, responsible for compiling source code into executable files. Cangjie uses ahead-of-time (AOT) compilation, generating binary files that can be executed directly on the target platform without a virtual machine or interpreter.
Use cjc hello.cj to compile a single source file, which defaults to outputting an executable named main. Use the -o option to specify the output filename, such as cjc hello.cj -o myapp. If source files are organized as a package structure, you can use cjc -p src/ to compile the entire package at once.
Optimization is enabled by default during compilation. Use the -g option to generate an executable with debug information, which can be used with debugging tools. The generated binary file contains user code and necessary runtime components, and can be deployed and run directly.
The code on the right shows a simple Cangjie program. Compile and run it to observe the output.
CANGJIE_HOME environment variable is configured correctly for the cjc command to work properly.Try modifying the output filename by using -o yourname to specify a custom name.