在 CentOS 上学习 C++ 开发,可以从「环境搭建 → 基础语法 → 工程实践 → 进阶方向」一步步来。下面给你一套可操作的学习路线。
CentOS 默认可能没装完整开发工具:
sudo yum groupinstall "Development Tools"
检查 g++ 是否安装:
g++ --version
如果没有:
sudo yum install gcc-c++
轻量级(推荐新手)
vim(系统自带)VSCode(远程 SSH 开发很方便)安装 VSCode(本地 Windows/Mac 连接 CentOS):
重量级
mkdir cpp_learn
cd cpp_learn
vim hello.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello CentOS C++" << endl;
return 0;
}
g++ hello.cpp -o hello
./hello
vectormapsetalgorithmall:
g++ main.cpp -o app
clean:
rm -f app
使用:
make
./app
make clean
fstreamopen / read / writefork / execsudo yum install pthread
#include <thread>
✅ 多写代码,少抄
✅ 每学一个概念就写 demo
✅ 学会看错误信息
✅ 熟悉 Linux 命令行
如果你愿意,我可以:
你现在是 完全零基础 还是 有别的语言基础?