.vscode文件夾下,配置以下三個文件:
c_cpp_properties.json // compiler path and IntelliSense settings
tasks.json // compiler build settings
launch.json // debugger settings
新建工程,可直接拷貝這三個文件,根據需要修改註釋部分 的配置。
1. c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/EigenArduino_Eigen30" //自定義、庫等 頭文件 所在目錄
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:\\Mingw-w64\\mingw64\\bin\\g++.exe", //mingw64安裝路徑
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
2.tasks.json
配置完成後Ctrl +Shift + b 進行build;
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build hand",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-I",
"./EigenArduino_Eigen30", //**** include目錄
"-o",
"Thumb_test", //*** build生成的可執行文件名
//*********** 以下是相關的.cpp文件
"test_HandManipulatePlan.cpp",
"HandManipulatePlan.cpp",
"Hand.cpp",
"ThumbKinematicFast.cpp",
"ThumbKinematic.cpp",
"FingerController.cpp",
"utils.cpp",
"FingerModule.cpp",
"can.cpp",
"-L",
"./can",//**** lib目錄
"ControlCAN.dll"//**** 動態鏈接庫
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
}
]
}
3.launch.json
{
// 使用 IntelliSense 瞭解相關屬性。
// 懸停以查看現有屬性的描述。
// 欲瞭解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Thumb_test.exe", //**** 要運行的可執行文件
"args": ["1","2"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\Mingw-w64\\mingw64\\bin\\gdb.exe", //*** mingw64路徑
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}