C语言 如何设置和运行树莓派皮科W蓝牙示例?

pepwfjgg  于 2023-10-16  发布在  其他
关注(0)|答案(2)|浏览(102)

我尝试在pico-sdk中运行spp_counter. c示例。当我运行make时,我得到这个错误:

fatal error: btstack.h: No such file or directory
58 | #include "btstack.h"

代码来自the repository。CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

# initialize the SDK based on PICO_SDK_PATH
# Include build functions from Pico SDK
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(my_project)

# initialize the Raspberry Pi Pico SDK
set(PICO_BOARD pico_w)

pico_sdk_init()

# rest of your project
add_executable(test
    test.c
)

# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(test pico_stdlib)

# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(test)

我不知道我错过了什么。

ru9i0ody

ru9i0ody1#

我也遇到了同样的问题,直到我看到standalone examples。有一个btstack_config.h必须包含在内,还有一些库需要链接,请查看CMakeLists.txt以了解您需要添加到自己的CMakeLists文件中的内容。所有的例子都在同一个文件中,但是核心蓝牙库被链接到所有的可执行文件,所以它们很容易被发现。

target_link_libraries(picow_ble_temp_sensor # executable
    pico_stdlib # standard lib, pretty much always linked
    pico_btstack_ble # Needed for ble
    pico_btstack_cyw43 # Needed for ble
    pico_cyw43_arch_none # Needed for pico_w
    hardware_adc # don't think it's needed (but haven't tested)
    )
target_include_directories(picow_ble_temp_sensor PRIVATE
    ${CMAKE_CURRENT_LIST_DIR} # For btstack config (copy their file)
    )

确保你也更新了子模块update git submodule update --init

tv6aics1

tv6aics12#

提示:在SDK目录中尝试'git submodule update --init'

相关问题