faster rcnn或bottom up attention编译lib时6/include/stddef.h(436): error: identifier “nullptr“ is undefin

解决这个问题花了我近一天半的时间,真是翻尽了百度、谷歌的网页,现将问题和对应的解决方法记录如下:

报错提示:

python setup.py build_ext --inplace

running build_ext

skipping 'utils/bbox.c' Cython extension (up-to-date)

skipping 'nms/cpu_nms.c' Cython extension (up-to-date)

skipping 'nms/gpu_nms.cpp' Cython extension (up-to-date)

skipping 'pycocotools/_mask.c' Cython extension (up-to-date)

building 'nms.gpu_nms' extension

/usr/bin/nvcc -I/home/haoyiming/.conda/envs/caffe/lib/python3.6/site-packages/numpy/core/include -I/usr/include -I/home/haoyiming/.conda/envs/caffe/include/python3.6m -c nms/nms_kernel.cu -o build/temp.linux-x86_64-3.6/nms/nms_kernel.o -arch=sm_35 --ptxas-options=-v -c --compiler-options '-fPIC'

/usr/lib/gcc/x86_64-linux-gnu/6/include/stddef.h(436): error: identifier "nullptr" is undefined

/usr/lib/gcc/x86_64-linux-gnu/6/include/stddef.h(436): error: expected a ";"

/usr/include/x86_64-linux-gnu/c++/6/bits/c++config.h(205): error: expected a ";"

/usr/include

FAILED: LED.elf cmd.exe /C "cd . && D:\esp\tools\xtensa-esp-elf\esp-13.2.0_20240530\xtensa-esp-elf\bin\xtensa-esp32s3-elf-g++.exe -mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32S3=0 -Wl,--Map=E:/espdemo/LED/build/LED.map -Wl,--no-warn-rwx-segments -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T esp32s3.peripherals.ld -T esp32s3.rom.ld -T esp32s3.rom.api.ld -T esp32s3.rom.libgcc.ld -T esp32s3.rom.wdt.ld -T esp32s3.rom.version.ld -T esp32s3.rom.newlib.ld -T memory.ld -T sections.ld @CMakeFiles\LED.elf.rsp -o LED.elf && cd ." D:/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/BLE/libBLE.a(ble_service.c.obj):(.literal.gap_event_handler+0x20): undefined reference to `esp_ble_gap_start_advertising' D:/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/BLE/libBLE.a(ble_service.c.obj):(.literal.gatts_event_handler+0x48): undefined reference to `esp_ble_gap_config_adv_data' D:/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/BLE/libBLE.a(ble_service.c.obj): in function `gap_event_handler': E:/espdemo/LED/components/BLE/ble_service.c:52:(.text.gap_event_handler+0x3b): undefined reference to `esp_ble_gap_start_advertising' D:/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/BLE/libBLE.a(ble_service.c.obj): in function `gatts_event_handler': E:/espdemo/LED/components/BLE/ble_service.c:89:(.text.gatts_event_handler+0xa8): undefined reference to `esp_ble_gap_config_adv_data' D:/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: E:/espdemo/LED/components/BLE/ble_service.c:120:(.text.gatts_event_handler+0x127): undefined reference to `esp_ble_gap_start_advertising' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. * 终端进程“d:\esp\tools\ninja\1.11.1\ninja.EXE”已终止,退出代码: 1。 * 正在执行任务: d:\esp\tools\ninja\1.11.1\ninja.EXE [0/1] Re-running CMake...-- ccache will be used for faster recompilation -- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git' -- Could not use 'git describe' to determine PROJECT_VER. -- Building ESP-IDF components for target esp32s3 CMake Error at C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/build.cmake:268 (message): Failed to resolve component 'bluedroid'. Call Stack (most recent call first): C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/build.cmake:304 (__build_resolve_and_add_req) C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/build.cmake:305 (__build_expand_requirements) C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/build.cmake:607 (__build_expand_requirements) C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/project.cmake:710 (idf_build_process) CMakeLists.txt:8 (project) -- Configuring incomplete, errors occurred! See also "E:/espdemo/LED/build/CMakeFiles/CMakeOutput.log". ninja: error: rebuilding 'build.ninja': subcommand failed FAILED: build.ninja D:\esp\tools\cmake\3.24.0\bin\cmake.exe --regenerate-during-build -SE:\espdemo\LED -BE:\espdemo\LED\build * 终端进程“d:\esp\tools\ninja\1.11.1\ninja.EXE”已终止,退出代码: 1。
最新发布
10-24
你遇到的错误有两个阶段的问题: --- ### ❌ 第一阶段:CMake 配置失败(`Failed to resolve component 'bluedroid'`) ``` CMake Error at C:/Espressif/frameworks/esp-idf-v5.3.1/tools/cmake/build.cmake:268 (message): Failed to resolve component 'bluedroid'. ``` 这说明你的项目中引用了 `bluedroid` 组件,但 **ESP-IDF v5.x 已经弃用了 Bluedroid**,改用 **BLE Host (NimBLE)** 架构。如果你在 `CMakeLists.txt` `idf_component.yml` 中显式依赖了 `bluedroid`,就会导致这个错误。 --- ### ❌ 第二阶段:链接错误(`undefined reference to esp_ble_gap_start_advertising` 等) 这些是典型的 BLE API 找不到符号的链接错误: ```text undefined reference to `esp_ble_gap_start_advertising' undefined reference to `esp_ble_gap_config_adv_data' ``` 这意味着虽然你在代码中调用了 ESP-IDF 的 BLE GAP 接口函数,但是编译系统没有正确链接对应的库(通常是 `bt` `esp_bt` 组件未启用配置错误)。 --- ## ✅ 解决方案 ### ✅ 步骤 1:确认使用正确的蓝牙架构(NimBLE 而非 Bluedroid) 从 ESP-IDF v4.4 开始,官方推荐并默认使用 **NimBLE stack** 来替代旧的 Bluedroid。 因此你需要确保: - 不要再使用 `bluedroid`。 - 改为使用 `BT_ENABLED` 和 `CONFIG_BT_NIMBLE_ENABLED` `CONFIG_BT_BLUEDROID_ENABLED=n`。 > ⚠️ 注意:**v5.3.1 默认禁用 Bluedroid,只支持 NimBLE(低功耗蓝牙 BLE)作为主机协议栈。** --- ### ✅ 步骤 2:修改 `sdkconfig.defaults` 通过 `menuconfig` 启用 NimBLE 运行: ```bash idf.py menuconfig ``` 然后设置以下选项: #### 导航路径: ``` Component config ---> Bluetooth controller ---> [✓] Compile time choice of Bluetooth controller → (LE) Low Energy Bluetooth Enabled ---> [*] Enable Bluetooth Bluetooth LE Controller ---> [*] Include default LE controller implementation NimBLE Host Stack ---> [*] Enable NimBLE host [*] GATT server [*] GATT client ``` 保存退出后会生成 `.config` 文件。 --- ### ✅ 步骤 3:更新 `CMakeLists.txt`(主项目和组件) #### 主项目的 `CMakeLists.txt` 示例: ```cmake # CMakeLists.txt (project level) cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(LED) ``` #### 组件 `components/BLE/CMakeLists.txt` 示例: ```cmake # components/BLE/CMakeLists.txt set(COMPONENT_REQUIRES bt) set(COMPONENT_ADD_INCLUDEDIRS include) register_component() ``` > 关键点:`COMPONENT_REQUIRES bt` 表示该组件依赖蓝牙底层驱动(包含 `esp_ble_*` 函数),否则链接器找不到这些函数。 --- ### ✅ 步骤 4:检查 `components/BLE/ble_service.c` 是否使用正确 API 由于你现在使用的是 **NimBLE**,而不是 Bluedroid,某些 API 是不同的! 但注意!你说的是 `esp_ble_gap_config_adv_data` 和 `esp_ble_gap_start_advertising` —— 这些其实是 **Bluedroid 的 API**! ⚠️ 在 **NimBLE 模式下,这些函数不可用!** 你必须切换到 **NimBLE 的 API**,者——更常见的是: --- ## 🔁 方案选择 A:改用 Bluedroid(如果你想继续用 `esp_ble_gap_*`) 如果你坚持要用 `esp_ble_gap_config_adv_data`、`esp_ble_gap_start_advertising` 这类函数,那你应该 **启用 Bluedroid 而不是 NimBLE**。 ### ✔ 修改配置以启用 Bluedroid: 运行: ```bash idf.py menuconfig ``` 进入: ``` Component config ---> Bluetooth Enabled ---> [*] Enable Bluetooth [*] Enable Bluetooth controller [*] Include default Bluetooth controller implementation Bluetooth controller ---> (Bluetooth Controller) Compile time choice of Bluetooth controller Bluedroid Bluetooth stack ---> [*] Enable Bluedroid ---> Choose "BLE" or "BT + BLE" ``` 同关闭 NimBLE: ``` NimBLE Host Stack ---> [ ] Disable NimBLE ``` 保存后重新构建。 此你可以正常使用如下代码: ```c #include "esp_bt.h" #include "esp_bt_main.h" #include "esp_gap_ble_api.h" #include "esp_gatts_api.h" // 示例广告数据 static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, .min_interval = 0x20, .max_interval = 0x40, .appearance = 0x00, .manufacturer_len = 0, .p_manufacturer_data = NULL, .service_data_len = 0, .p_service_data = NULL, .service_uuid_len = 0, .p_service_uuid = NULL, .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT), }; void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { switch (event) { case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT: esp_ble_gap_start_advertising(&adv_params); // 开始广播 break; default: break; } } void app_main(void) { esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); esp_bt_controller_init(&bt_cfg); esp_bt_controller_enable(ESP_BT_MODE_BLE); esp_bluedroid_init(); esp_bluedroid_enable(); esp_ble_gap_register_callback(gap_event_handler); esp_ble_gap_config_adv_data(&adv_data); // 配置广告数据 } ``` > 上面这段代码只能在 **启用了 Bluedroid** 的情况下工作。 --- ## ✅ 总结解决方案流程 | 问题 | 原因 | 解法 | |------|------|------| | `Failed to resolve component 'bluedroid'` | CMake 找不到 bluedroid 组件 | 删除对 `bluedroid` 的硬依赖,改为通过 menuconfig 控制 | | `undefined reference to esp_ble_gap_*` | 使用了 Bluedroid API 但未启用 Bluedroid | 启用 Bluedroid 协议栈(menuconfig) | | 编译失败 | 组件未声明依赖 `bt` | 在组件 `CMakeLists.txt` 加上 `set(COMPONENT_REQUIRES bt)` | --- ## ✅ 最终建议操作步骤 1. 删除 `build` 目录。 2. 在 `menuconfig` 中: - 启用 **Bluetooth** - 启用 **Bluedroid** - 禁用 **NimBLE** 3. 确保组件 `components/BLE/CMakeLists.txt` 包含: ```cmake set(COMPONENT_REQUIRES bt) register_component() ``` 4. 保证主工程已初始化 Bluedroid: ```c esp_bt_controller_enable(ESP_BT_MODE_BLE); esp_bluedroid_init(); esp_bluedroid_enable(); ``` 5. 重新编译: ```bash idf.py build ``` --- ### ✅ 补充说明:如何判断当前使用的是哪种协议栈? | 特征 | Bluedroid | NimBLE | |------|----------|--------| | 头文件 | `#include "esp_gap_ble_api.h"` | `#include "nimble/nimble_port.h"` | | 初始化 | `esp_bluedroid_init()` | `nimble_port_init()` | | 广播函数 | `esp_ble_gap_config_adv_data()` | `ble_gap_adv_set_fields()` | | 回调机制 | `esp_gap_ble_cb_t` | `struct ble_gap_event` 回调 | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值