VSCode编译环境搭建教程

VSCode编译环境搭建

1.下载编译器MinGW

(MinGW:Minimalist GNU for Windows)

(1)官网下载(可以翻墙的条件下)

此部分可以参考CSDN博客:https://blog.csdn.net/bat67/article/details/76095813

==(注:不翻墙下载的文件会不完整)==

(2)下载pixhawk集成工具包

下载地址:http://firmware.ardupilot.org/Tools/PX4-tools/pixhawk_toolchain_installer_latest.exe

2.VSCode调试环境配置

参考官方文档:https://code.visualstudio.com/docs/languages/cpp

VSCode下配置C/C++调试参数的文件有三个:

(1) 找不到包含的库时(如果安装了ms-vscode.cpptools第三方插件,会有波浪线)按下Ctrl+Shift+P会生成一个c_cpp_properties.json文件,==c_cpp_properties.json文件指定库文件夹==。示例代码如下:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
               "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

(2)Ctrl+Shift+P打开命令板,选择Tasks: Configure Tasks,点击 tasks.json file from templates,继续点击Others,这时会生成tasks.json文件。==tasks.json文件指定编译器和生成文件==。示例代码如下:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build eigen",
            "type": "shell",
            "command": "g++",
            "args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

(3)为了能进行调试,需要launch.json文件。按F5或这点击调试会生成该文件。==launch.json指定调试器和要调试的exe文件==。示例代码如下:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/eigen.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\pixhawk_toolchain\\toolchain\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build eigen"
        }
    ]
}

至此,调试参数配置完成。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值