windows vscode 配置cmake 编译c/c++ 基础

简介: 1. 下载基础包; 2. 配置vscode; 3. cmake 基础


1. 下载基础包; 2. 配置vscode; 3. cmake 基础

################### 软件下载 ###################

vscode:
官方:      https://code.visualstudio.com/Download
其他下载:  http://work.eisc.cn/ruanjian/windows/c/ruanjian/VSCodeUserSetup-x64-1.75.1.exe

cmake:
官方:      https://cmake.org/download/
其他下载:  http://work.eisc.cn/ruanjian/windows/c/ruanjian/cmake-3.26.0-rc4.zip

gcc_g++:
其他下载:  http://work.eisc.cn/ruanjian/windows/c/ruanjian/windos_mingw64.tar.gz

# 该文件中 目录 mingw64\bin\mingw32-make.exe  中的文件 已经重命名为 make.exe 为了解决下面 没有识别到make 命令 问题:

CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!



################### vscode 基础配置 ###################
vscode 配置为中文:
        1. 点击 vscode 左侧的扩展图标,打开侧边栏“EXTENSIONS”面板(魔方图标)
        2. 点击搜索并安装 chinese 简体中文 
        3. 安装完成,点击右下角 Restart 重启 vscode


配置 gcc c++ :
        1. 我的电脑-> 属性 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> Path -> 添加上面软件解压的路径,精确到bin目录 -> 重启电脑
        2. 搜索安装 C/C++ Extension Pack  (Popular extensions for C++ development in Visual Studio Code.)  -> 重启电脑
        3. 重启电脑后,可以看到 vscode 左下角的 状态栏 图标出现cmake 右边一个图标的扳手 No kit Selected ,点击它 -> 选择 GCC 8.1

如果 vscode 左下角还是没有出现 cmake 的功能,使用: Shift+Ctrl+p 弹出搜索 -> 输入cmake -> 点击 cmake 配置,自动弹出提示进行 选择  yes

################### cmake 基础使用 ###################

#--- 编译命令 ---#
点击 vscode 顶部状态栏 -> 终端 -> 新建终端  输入下面命令进行编译
mkdir build ; cd build 
# 创建 build 编译目录, 并且进入

del * ; cmake ../ -Bbuild -G "Unix Makefiles" ; cmake --build build 
# 删除build的目录所有文件
# cmake 构建命令
# cmake 编译

#--- cmake 案例 ---#
project(eisc)
#项目名
cmake_minimum_required(VERSION 3.10)
# 编译要求:cmake 要大于最低版本 3.1 
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
# 设置编译器, 如果没有配置环境变量,可以改为gcc具体文件路径

include_directories(../../test/include/)
include_directories(../../uds/)
include_directories(../../include/)   
include_directories(../../driver/)
include_directories(../../core/)
# 添加 头文件搜索路径 (.h 搜索路径)

add_executable("test.exe" test.cpp)
# 生成可执行文件: 将 test.cpp 编译成 test.exe 可执行文件



目录
相关文章
|
25天前
|
Java 应用服务中间件 开发工具
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
|
25天前
|
Java 应用服务中间件 Windows
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
|
1月前
|
安全 机器人 程序员
Windows 计划任务每天隔 3 小时运行一次批处理文件详细配置步骤
Windows 计划任务每天隔 3 小时运行一次批处理文件详细配置步骤
115 2
|
21天前
|
网络安全 Windows
在Windows电脑上启动并配置SSH服务
在Windows电脑上启动并配置SSH服务
44 0
|
21天前
|
Ubuntu Linux 数据安全/隐私保护
在 Windows 中配置 WSL2 与 Debian 的全流程
【8月更文挑战第27天】本文详细介绍了在Windows环境中配置WSL2与Debian的全过程,包括确认Windows版本、启用相关功能、安装WSL并设置版本为WSL2、下载安装Debian、配置国内镜像源,以及设置Xserver实现GUI功能。通过这些步骤,用户能够顺利完成配置,并进行基本优化。
|
26天前
【Azure 应用服务】App Service 配置 Application Settings 访问Storage Account得到 could not be resolved: '*.file.core.windows.net'的报错。没有解析成对应中国区 Storage Account地址 *.file.core.chinacloudapi.cn
【Azure 应用服务】App Service 配置 Application Settings 访问Storage Account得到 could not be resolved: '*.file.core.windows.net'的报错。没有解析成对应中国区 Storage Account地址 *.file.core.chinacloudapi.cn
|
27天前
|
JavaScript Java Python
【Azure 应用服务】在Azure App Service for Windows 中部署Java/NodeJS/Python项目时,web.config的配置模板内容
【Azure 应用服务】在Azure App Service for Windows 中部署Java/NodeJS/Python项目时,web.config的配置模板内容
|
1天前
|
编译器 C++
C++ 类构造函数初始化列表
构造函数初始化列表以一个冒号开始,接着是以逗号分隔的数据成员列表,每个数据成员后面跟一个放在括号中的初始化式。
39 30
|
15天前
|
存储 编译器 C++
C ++初阶:类和对象(中)
C ++初阶:类和对象(中)
|
1月前
|
存储 安全 编译器
【C++】类和对象(下)
【C++】类和对象(下)
【C++】类和对象(下)