4. ESP-IDF wss範例專案問題

idf.py menuconfig時出現錯誤
CMake Error at C:/Users/nomo9/esp/esp-idf/tools/cmake/utilities.cmake:108 (target_sources):
Cannot specify sources for target "mqtt_websocket_secure.elf" which is notbuilt by this project.Call Stack (most recent call first):
CMakeLists.txt:12 (target_add_binary_data)

問題說明:
無法為 “mqtt_websocket_secure.elf” 目標指定源文件,因為這個目標不是由這個專案構建的。這種問題通常是由於 CMakeLists.txt 文件配置不正確或文件結構問題所導致的。
錯誤信息提到了 target_add_binary_data 函數在 CMakeLists.txt 的第12行有問題。這個函數用於將二進位數據(在這個案例中是 PEM 文件)添加到構建目標中。如果 mqtt_websocket_secure.elf 目標不存在或者在這個階段還沒有被定義,就會導致這個錯誤。

解決方式:
原始CMakeLists.txt

# The following four lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

# (Not part of the boilerplate)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(websockets)

target_add_binary_data(mqtt_websocket_secure.elf "main/mqtt_eclipseprojects_io.pem" TEXT)

替換成

# The following four lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

# (Not part of the boilerplate)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId})

target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/mqtt_eclipseprojects_io.pem" TEXT)
Visited 5 times, 1 visit(s) today

留言

在〈4. ESP-IDF wss範例專案問題〉中有 1 則留言

  1. 「Vanessa」的個人頭像
    Vanessa

    終於找到原因了
    還以為是Python版本問題
    太感謝

發佈回覆給「Vanessa」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *