当前位置: 首页 > article >正文

VSCode C语言环境(多文件一键运行)

配置CMake

下载CMake并安装

https://cmake.org/download/

配置mingw64

https://github.com/niXman/mingw-builds-binaries/releases
i686-14.2.0-release-mcf-dwarf-ucrt-rt_v12-rev1.7z
i686-14.2.0-release-posix-dwarf-msvcrt-rt_v12-rev1.7z
i686-14.2.0-release-posix-dwarf-ucrt-rt_v12-rev1.7z
i686-14.2.0-release-win32-dwarf-msvcrt-rt_v12-rev1.7z
i686-14.2.0-release-win32-dwarf-ucrt-rt_v12-rev1.7z
x86_64-14.2.0-release-mcf-seh-ucrt-rt_v12-rev1.7z
x86_64-14.2.0-release-posix-seh-msvcrt-rt_v12-rev1.7z
x86_64-14.2.0-release-posix-seh-ucrt-rt_v12-rev1.7z
x86_64-14.2.0-release-win32-seh-msvcrt-rt_v12-rev1.7z
x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev1.7z

这里有很多版本:

  • x86_64i68664位32位的区别,sehdwarf分别专用于此
  • posixwin32线程模型的区别,posix跨平台,win32性能好
  • ucrtmsvcrt运行时库的区别,ucrt只有win10+支持

现在都是win10以上的系统了,肯定选x86_64-14.2.0-release-posix-seh-ucrt-rt_v12-rev1.7z

下载解压后,将bin文件夹添加到环境变量,其中包括了gccmake

配置VSCODE

安装CMake Tools插件

在工作区创建两个源文件

main.c

#include <stdio.h>
extern void test_cmake();
int main(int argc, char const *argv[])
{
    test_cmake();
    printf("Hello, World!\n");
    return 0;
}

test_cmake.c

#include "stdio.h"
void test_cmake()
{
    printf("Hello from test_cmake\n");
}

在工作区创建CMakeLists.txt,输入如下内容后,左下角就会生成调试和运行按钮

cmake_minimum_required(VERSION 3.10)

# Set the project name
project(TEST_C)

# Add all .c files in the current directory
file(GLOB SOURCES "*.c")

# Add an executable
add_executable(main ${SOURCES})

http://www.kler.cn/a/587415.html

相关文章:

  • 面试求助:接口测试用例设计主要考虑哪些方面?
  • Linux 》》Ubuntu 18 LTS 之后的版本 修改IP地址 主机名
  • Java使用JDBC连接操作Sqlite 笔记250314
  • 工程化与框架系列(34)--前端重构技巧指南
  • 蓝耘携手通义万象 2.1 图生视频:开启创意无限的共享新时代
  • 基于Python+Flask+MySQL+HTML的爬取豆瓣电影top-250数据并进行可视化的数据可视化平台
  • 【论文精读】DifFace: Blind Face Restoration with Diffused Error Contraction
  • 【C++】如何高效掌握UDP数据包解析
  • 设计模式之责任链设计模式
  • 2.2.3 TCP—UDP-QUIC
  • 星越L_内后视镜使用讲解
  • 电子招采软件系统,如何实现10年可追溯审计
  • Spring、Spring Boot、Spring Cloud 的区别与联系
  • 矫平机:解锁精密制造的工业之手
  • (学习总结28)Linux 基本命令3
  • odbus TCP转Modbus RTU网关快速配置案例
  • 深入理解Spring MVC:构建灵活的Web应用
  • python3GUI--模仿安卓桌面 By:PyQt5(附下载地址)
  • 破碎的誓言
  • 【打卡D6】二分法