在 Ubuntu 上进行 C++ 开发,通常需要安装编译工具链和相关辅助工具。下面按最常用 → 可选分类说明。
sudo apt update
sudo apt install build-essential
包含:
gcc(C 编译器)g++(C++ 编译器)make验证:
g++ --version
sudo apt install gdb
sudo apt install cmake
sudo apt install git
sudo apt install libstdc++-dev
g++ -std=c++17 test.cpp
# 数学/算法
sudo apt install libboost-all-dev
# 网络
sudo apt install libcurl4-openssl-dev
# JSON
sudo apt install nlohmann-json3-dev
# 多线程/并发
sudo apt install libpthread-stubs0-dev
sudo apt install code # VS Code
sudo apt install clion # 需手动安装
// hello.cpp
#include <iostream>
int main() {
std::cout << "Hello C++" << std::endl;
}
编译运行:
g++ hello.cpp -o hello
./hello
如果你愿意,可以告诉我:
我可以给你一套精准配置方案。