2.2. 编译源文件
使用 Clang 编译器编译源文件和装配语言源文件。clang 会创建一个可执行的二进制文件,作为编译的结果。要能够调试代码,通过在 Clang 命令中添加 -g 标志来启用调试信息。
注意
要编译 C++ 程序,请使用 clang++ 而不是 clang。
流程
要编译程序,请运行以下命令:
在 Red Hat Enterprise Linux 8 中:
clang -o -g <binary_file> <source_file>
$ clang -o -g <binary_file> <source_file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
将
<binary_file> 替换为输出文件所需的名称,将<source_file> 替换为源文件的名称。
-
将
在 Red Hat Enterprise Linux 9 中:
clang -o -g <binary_file> <source_file>
$ clang -o -g <binary_file> <source_file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
将
<binary_file> 替换为输出文件所需的名称,将<source_file> 替换为源文件的名称。
-
将