← 返回命令列表

Linux command

c++ 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Compile

c++ [program.cpp] -o [program]

Compile

c++ -O2 [program.cpp] -o [program]

Compile

c++ -g [program.cpp] -o [program]

Specify

c++ -std=c++17 [program.cpp] -o [program]

Link

c++ [program.cpp] -o [program] -l[library]

说明

c++ is typically a symlink to the system's C++ compiler (g++ or clang++). It compiles C++ source code into executable programs or object files, handling preprocessing, compilation, and linking. The command provides access to the C++ compiler with standard naming convention.

参数

-o _file_
Output file name
-c
Compile without linking
-g
Include debug information
-O_level_
Optimization level (0, 1, 2, 3, s)
-std=_standard_
C++ standard (c++11, c++14, c++17, c++20, c++23)
-Wall
Enable all warnings
-Werror
Treat warnings as errors
-I _dir_
Add include directory
-L _dir_
Add library directory
-l _lib_
Link library

FAQ

What is the c++ command used for?

c++ is typically a symlink to the system's C++ compiler (g++ or clang++). It compiles C++ source code into executable programs or object files, handling preprocessing, compilation, and linking. The command provides access to the C++ compiler with standard naming convention.

How do I run a basic c++ example?

Run `c++ [program.cpp] -o [program]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _file_ do in c++?

Output file name