C++环境搭建

1.安装mingw64

下载地址:https://sourceforge.net/projects/mingw-w64/files/

Toolchains targetting Win64 → Personal Builds → mingw-builds → 8.1.0 
‌64位系统‌ → threads-posix → seh 
  • posix:兼容多线程开发
  • seh:高性能异常处理机制

解压到英文目录

添加到环境变量

gcc --version

g++ --version

2.下载vscode

安装 VS Code:https://code.visualstudio.com/

安装 C++ 扩展:
  • 打开 VS Code,点击左侧扩展图标(或按 Ctrl+Shift+X)。
  • 搜索并安装 C/C++ 扩展(由 Microsoft 提供)。

 3.开始写代码

  • 创建项目文件夹,例如 C++_Projects
  • 在文件夹中创建 main.cpp 文件,输入示例代码

 

#include <iostream>
int main() {
    std::cout << "Hello, C++!" << std::endl;
    return 0;
}

 

  • 按 Ctrl+Shift+B 编译代码,选择 g++ 生成任务。
  • 运行生成的 a.exe(Windows)或 a.out(macOS/Linux)。
posted @ 2025-06-29 16:26  zwx901323  阅读(52)  评论(0)    收藏  举报