VScode编译报错:正在执行任务: CMake: build build failed. * 终端进程启动失败(退出代码: -1)。 * 终端将被任务重用,按任意键关闭。

主要原因是:没有 source 工作空间的 devel/setup.bash
task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Catkin: build",
"command": "bash",
"args": [
"-lc",
"cd \"${workspaceFolder}\" && if [ -f devel/setup.bash ]; then source devel/setup.bash; fi && catkin_make"
],
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"reveal": "always",
"panel": "shared"
},
"group": {"kind":"build", "isDefault": true},
"problemMatcher": ["$gcc"],
"detail": "Catkin_make template build task"
}
]
}
bash -lc "..." 可保证在一段干净的 shell 环境中先 source ROS,再执行 catkin_make,可避免 catkin_make: command not found。


浙公网安备 33010602011771号