You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code调试CMake项目时旧项目名附加到make目标的问题求助

VS Code调试CMake项目时旧项目名被附加到make目标前的问题

启动VS Code调试会话时出现异常:旧CMake项目名pico_micro_ros_example会被自动附加到make目标前,终端输出的启动命令如下:

[main] Building folder: micro_ros_raspberrypi_pico_sdk pico_micro_ros_example, basic_uart
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/USER/src/micro_ros_raspberrypi_pico_sdk/build --config Debug --target pico_micro_ros_example basic_uart -j 10 --

项目使用CMake Tools扩展,以C语言为主。将示例代码拆分到子目录并把项目名修改为pico_examples之前,所有调试流程均正常。

补充说明

  • 旧项目名pico_micro_ros_example已修改为pico_examples,项目内已无该旧名称的任何引用
  • 手动在build目录执行CMake调试命令和make命令可正常完成构建
  • 执行以下命令可正常运行(此命令为F5调试时生成的命令去掉旧项目名后的版本):
/usr/bin/cmake --build /home/tor/src/micro_ros_raspberrypi_pico_sdk/build --config Debug --target basic_subscriber_uart -j 10 --
  • 已尝试重启电脑、重启VS Code、重装CMake Tools等操作,问题仍未解决

相关配置文件

launch.json配置

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Pico Debug",
            "cwd": "${workspaceRoot}",
            "executable": "${command:cmake.launchTargetPath}",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "openOCDLaunchCommands": ["adapter speed 5000"],
            "gdbPath" : "gdb-multiarch",
            "device": "RP2040",
            "showDevDebugOutput": "raw",
            "configFiles": [
                "interface/cmsis-dap.cfg",
                "target/rp2040.cfg"
            ],
            "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
            "runToEntryPoint": "main",
            "postRestartCommands": [
                "break main",
                "continue"
            ]
        }
    ]
}

根目录CMakeLists.txt

cmake_minimum_required(VERSION 3.12)

include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(pico_example C CXX ASM)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

link_directories(libmicroros)

add_subdirectory(examples)

SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")

add_compile_options(-Wall
        -Wno-format          # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
        -Wno-unused-function # we have some for the docs that aren't called
        )
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
    add_compile_options(-Wno-maybe-uninitialized)
endif()

示例子目录CMakeLists.txt(省略中间子目录配置)

add_executable(basic_subscriber_uart
    basic_subscriber_uart.c
    uart_transport.c
)
target_link_libraries(basic_subscriber_uart
    pico_stdlib
    hardware_uart
    microros
)

target_include_directories(basic_subscriber_uart PUBLIC
    ../../../libmicroros/include
    ../../../include
)

# Configure Pico
pico_enable_stdio_usb(basic_subscriber_uart 0)
pico_enable_stdio_uart(basic_subscriber_uart 1)
add_compile_definitions(PICO_UART_ENABLE_CRLF_SUPPORT=0)
add_compile_definitions(PICO_STDIO_ENABLE_CRLF_SUPPORT=0)
add_compile_definitions(PICO_STDIO_DEFAULT_CRLF=0)

# Generate UF2
pico_add_extra_outputs(basic_subscriber_uart)

cpp_properties.json配置

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/include",
                "${workspaceFolder}/libmicroros/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/arm-none-eabi-gcc",
            "cStandard": "c11",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

内容的提问来源于stack exchange,提问作者G. Debailly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 10:52:08