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"
}
]
}
至此,调试参数配置完成。