一个main.cpp如何在linux上编译和运行
时间: 2023-02-09 15:16:17 浏览: 151
linux下使用g++编译cpp工程的方法
5星 · 资源好评率100%
To compile and run a C++ program on Linux, you can use the following steps:
1. Open a terminal window.
2. Navigate to the directory where your C++ program is located. For example, if your program is named "main.cpp", you can use the following command to navigate to the directory where it is located:
cd /path/to/directory
3. Compile the program using the g++ compiler. You can use the following command to compile "main.cpp":
g++ main.cpp -o output
4. Run the program using the following command:
./output
Note that the "./" before "output" is necessary to run the program.
And that's it! Your C++ program should now be compiled and running on Linux.
阅读全文