Linux环境下,使用VSCode编译C++工程

本文详细介绍了如何在Linux环境中使用Visual Studio Code(VSCode)进行C++工程的编译和调试。首先,需要安装VSCode、GCC编译器和GDB调试器。接着,创建工程并配置launch.json和tasks.json文件,以实现编译和运行。在launch.json中设置调试配置,使调试器能在正确位置暂停。最后,通过settings.json可自定义编译器路径和标准。
摘要由CSDN通过智能技术生成

Linux环境下,使用VS Code编译C++工程

1. 准备

sudo apt-get install g++

或者更新

sudo apt-get update
  • 安装gdb调试器
sudo apt-get install build-essential gdb

2. 创建Hello World

VS Code需要为工程配置3个文件:

`tasks.json` :编译器配置

`launch.json`:调试器配置

`c_cpp_properties.json` (编译器路径、智能提示)
  • 创建Hello World工程
mkdir hello_world
cd hello_world
code .
  • 新建hello_world.cpp
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
   
    vector<string> msg {
   "Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

    for (
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值