- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我觉得这个问题已经被问过很多次了,但我找到的答案似乎都不适合我。我来自 Java 世界,因此对 CMake 和 C/C++ 非常陌生,并且正在努力理解 cmake 及其工作原理。
无论如何,基本上我有下面的文件夹结构。这是一个 esp-idf 项目,所以我不知道这是否与我遇到的问题有关。
main
-CMakeLists.txt
-main.cpp
-wifi.cpp
Metriful
-CMakeLists.txt
-Metriful_sensor.cpp
-Metriful_sensor.h
-Wifi_functions.h
-Wifi_functions.cpp
CMakeLists.txt
Makefile
现在,我只想包含 Metriful 子目录,这样我就可以使用“库”提供的功能。现在,我在根目录中的 CMakeLists.txt 如下所示:
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ESP_32_WROOM32_SENSOR_-_Metriful)
include_directories("Metriful")
这似乎不起作用,因为在我的 main.cpp 中包含“Metriful_sensor.h”仍然失败:
cmake -G Ninja .. <
-- ccache will be used for faster recompilation
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file C:/Users/User/PlatformIO/ESP32_WROOM32_Sensor_-_Metriful/sdkconfig
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
CMake Warning (dev) at C:/Users/User/esp/esp-idf/components/mbedtls/CMakeLists.txt:114 (target_sources):
Policy CMP0076 is not set: target_sources() command converts relative paths
to absolute. Run "cmake --help-policy CMP0076" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
A private source from a directory other than that of target "mbedcrypto"
has a relative path.
This warning is for project developers. Use -Wno-dev to suppress it.
-- App "ESP_32_WROOM32_SENSOR_-_Metrifu" version: 637cfde-dirty
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script C:/Users/User/PlatformIO/ESP32_WROOM32_Sensor_-_Metriful/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script C:/Users/User/esp/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Components: app_trace app_update asio bootloader bootloader_support bt cbor cmock coap console cxx driver efuse esp-tls esp32 esp_adc_cal esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_ipc esp_local_ctrl esp_netif esp_pm esp_ringbuf esp_rom esp_serial_slave_link esp_system esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos hal heap idf_test jsmn json libsodium log lwip main mbedtls mdns mqtt newlib nghttp nvs_flash openssl partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport tcpip_adapter tinyusb ulp unity vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: C:/Users/User/esp/esp-idf/components/app_trace C:/Users/User/esp/esp-idf/components/app_update C:/Users/User/esp/esp-idf/components/asio C:/Users/User/esp/esp-idf/components/bootloader C:/Users/User/esp/esp-idf/components/bootloader_support C:/Users/User/esp/esp-idf/components/bt C:/Users/User/esp/esp-idf/components/cbor C:/Users/User/esp/esp-idf/components/cmock C:/Users/User/esp/esp-idf/components/coap C:/Users/User/esp/esp-idf/components/console C:/Users/User/esp/esp-idf/components/cxx C:/Users/User/esp/esp-idf/components/driver C:/Users/User/esp/esp-idf/components/efuse C:/Users/User/esp/esp-idf/components/esp-tls C:/Users/User/esp/esp-idf/components/esp32 C:/Users/User/esp/esp-idf/components/esp_adc_cal C:/Users/User/esp/esp-idf/components/esp_common C:/Users/User/esp/esp-idf/components/esp_eth C:/Users/User/esp/esp-idf/components/esp_event C:/Users/User/esp/esp-idf/components/esp_gdbstub C:/Users/User/esp/esp-idf/components/esp_hid C:/Users/User/esp/esp-idf/components/esp_http_client C:/Users/User/esp/esp-idf/components/esp_http_server C:/Users/User/esp/esp-idf/components/esp_https_ota C:/Users/User/esp/esp-idf/components/esp_https_server C:/Users/User/esp/esp-idf/components/esp_hw_support C:/Users/User/esp/esp-idf/components/esp_ipc C:/Users/User/esp/esp-idf/components/esp_local_ctrl C:/Users/User/esp/esp-idf/components/esp_netif C:/Users/User/esp/esp-idf/components/esp_pm C:/Users/User/esp/esp-idf/components/esp_ringbuf C:/Users/User/esp/esp-idf/components/esp_rom C:/Users/User/esp/esp-idf/components/esp_serial_slave_link C:/Users/User/esp/esp-idf/components/esp_system C:/Users/User/esp/esp-idf/components/esp_timer C:/Users/User/esp/esp-idf/components/esp_websocket_client C:/Users/User/esp/esp-idf/components/esp_wifi C:/Users/User/esp/esp-idf/components/espcoredump C:/Users/User/esp/esp-idf/components/esptool_py C:/Users/User/esp/esp-idf/components/expat C:/Users/User/esp/esp-idf/components/fatfs C:/Users/User/esp/esp-idf/components/freemodbus C:/Users/User/esp/esp-idf/components/freertos C:/Users/User/esp/esp-idf/components/hal C:/Users/User/esp/esp-idf/components/heap C:/Users/User/esp/esp-idf/components/idf_test C:/Users/User/esp/esp-idf/components/jsmn C:/Users/User/esp/esp-idf/components/json C:/Users/User/esp/esp-idf/components/libsodium C:/Users/User/esp/esp-idf/components/log C:/Users/User/esp/esp-idf/components/lwip C:/Users/User/PlatformIO/ESP32_WROOM32_Sensor_-_Metriful/main C:/Users/User/esp/esp-idf/components/mbedtls C:/Users/User/esp/esp-idf/components/mdns C:/Users/User/esp/esp-idf/components/mqtt C:/Users/User/esp/esp-idf/components/newlib C:/Users/User/esp/esp-idf/components/nghttp C:/Users/User/esp/esp-idf/components/nvs_flash C:/Users/User/esp/esp-idf/components/openssl C:/Users/User/esp/esp-idf/components/partition_table C:/Users/User/esp/esp-idf/components/perfmon C:/Users/User/esp/esp-idf/components/protobuf-c
C:/Users/User/esp/esp-idf/components/protocomm C:/Users/User/esp/esp-idf/components/pthread C:/Users/User/esp/esp-idf/components/sdmmc C:/Users/User/esp/esp-idf/components/soc C:/Users/User/esp/esp-idf/components/spi_flash C:/Users/User/esp/esp-idf/components/spiffs C:/Users/User/esp/esp-idf/components/tcp_transport C:/Users/User/esp/esp-idf/components/tcpip_adapter C:/Users/User/esp/esp-idf/components/tinyusb C:/Users/User/esp/esp-idf/components/ulp C:/Users/User/esp/esp-idf/components/unity C:/Users/User/esp/esp-idf/components/vfs C:/Users/User/esp/esp-idf/components/wear_levelling C:/Users/User/esp/esp-idf/components/wifi_provisioning C:/Users/User/esp/esp-idf/components/wpa_supplicant C:/Users/User/esp/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/User/PlatformIO/ESP32_WROOM32_Sensor_-_Metriful/build
Terminal will be reused by tasks, press any key to close it.
> Executing task: cmake --build . <
[1/9] Performing build step for 'bootloader'
ninja: no work to do.
[2/7] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj
ccache C:\Users\User\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -IC:/Users/User/esp/esp-idf/components/newlib/platform_include -IC:/Users/User/esp/esp-idf/components/freertos/include -IC:/Users/User/esp/esp-idf/components/freertos/port/xtensa/include -IC:/Users/User/esp/esp-idf/components/esp_hw_support/include -IC:/Users/User/esp/esp-idf/components/esp_hw_support/port/esp32/. -IC:/Users/User/esp/esp-idf/components/heap/include -IC:/Users/User/esp/esp-idf/components/log/include -IC:/Users/User/esp/esp-idf/components/lwip/include/apps -IC:/Users/User/esp/esp-idf/components/lwip/include/apps/sntp -IC:/Users/User/esp/esp-idf/components/lwip/lwip/src/include -IC:/Users/User/esp/esp-idf/components/lwip/port/esp32/include -IC:/Users/User/esp/esp-idf/components/lwip/port/esp32/include/arch -IC:/Users/User/esp/esp-idf/components/soc/include -IC:/Users/User/esp/esp-idf/components/soc/esp32/. -IC:/Users/User/esp/esp-idf/components/soc/esp32/include -IC:/Users/User/esp/esp-idf/components/hal/esp32/include -IC:/Users/User/esp/esp-idf/components/hal/include -IC:/Users/User/esp/esp-idf/components/esp_rom/include -IC:/Users/User/esp/esp-idf/components/esp_rom/esp32 -IC:/Users/User/esp/esp-idf/components/esp_common/include -IC:/Users/User/esp/esp-idf/components/esp_system/include -IC:/Users/User/esp/esp-idf/components/esp32/include -IC:/Users/User/esp/esp-idf/components/driver/include -IC:/Users/User/esp/esp-idf/components/driver/esp32/include -IC:/Users/User/esp/esp-idf/components/esp_ringbuf/include -IC:/Users/User/esp/esp-idf/components/efuse/include -IC:/Users/User/esp/esp-idf/components/efuse/esp32/include -IC:/Users/User/esp/esp-idf/components/xtensa/include -IC:/Users/User/esp/esp-idf/components/xtensa/esp32/include -IC:/Users/User/esp/esp-idf/components/espcoredump/include -IC:/Users/User/esp/esp-idf/components/esp_timer/include -IC:/Users/User/esp/esp-idf/components/esp_ipc/include -IC:/Users/User/esp/esp-idf/components/esp_pm/include -IC:/Users/User/esp/esp-idf/components/vfs/include -IC:/Users/User/esp/esp-idf/components/esp_wifi/include -IC:/Users/User/esp/esp-idf/components/esp_wifi/esp32/include -IC:/Users/User/esp/esp-idf/components/esp_event/include -IC:/Users/User/esp/esp-idf/components/esp_netif/include -IC:/Users/User/esp/esp-idf/components/esp_eth/include -IC:/Users/User/esp/esp-idf/components/tcpip_adapter/include -IC:/Users/User/esp/esp-idf/components/app_trace/include -IC:/Users/User/esp/esp-idf/components/mbedtls/port/include -IC:/Users/User/esp/esp-idf/components/mbedtls/mbedtls/include -IC:/Users/User/esp/esp-idf/components/mbedtls/esp_crt_bundle/include -IC:/Users/User/esp/esp-idf/components/app_update/include -IC:/Users/User/esp/esp-idf/components/spi_flash/include -IC:/Users/User/esp/esp-idf/components/bootloader_support/include -IC:/Users/User/esp/esp-idf/components/nvs_flash/include -IC:/Users/User/esp/esp-idf/components/pthread/include -IC:/Users/User/esp/esp-idf/components/esp_gdbstub/include -IC:/Users/User/esp/esp-idf/components/esp_gdbstub/xtensa -IC:/Users/User/esp/esp-idf/components/esp_gdbstub/esp32 -IC:/Users/User/esp/esp-idf/components/wpa_supplicant/include -IC:/Users/User/esp/esp-idf/components/wpa_supplicant/port/include -IC:/Users/User/esp/esp-idf/components/wpa_supplicant/include/esp_supplicant -IC:/Users/User/esp/esp-idf/components/perfmon/include -IC:/Users/User/esp/esp-idf/components/asio/asio/asio/include -IC:/Users/User/esp/esp-idf/components/asio/port/include -IC:/Users/User/esp/esp-idf/components/cbor/port/include -IC:/Users/User/esp/esp-idf/components/unity/include -IC:/Users/User/esp/esp-idf/components/unity/unity/src -IC:/Users/User/esp/esp-idf/components/cmock/CMock/src -IC:/Users/User/esp/esp-idf/components/coap/port/include -IC:/Users/User/esp/esp-idf/components/coap/port/include/coap -IC:/Users/User/esp/esp-idf/components/coap/libcoap/include -IC:/Users/User/esp/esp-idf/components/coap/libcoap/include/coap2 -IC:/Users/User/esp/esp-idf/components/console -IC:/Users/User/esp/esp-idf/components/nghttp/port/include -IC:/Users/User/esp/esp-idf/components/nghttp/nghttp2/lib/includes -IC:/Users/User/esp/esp-idf/components/esp-tls -IC:/Users/User/esp/esp-idf/components/esp-tls/esp-tls-crypto -IC:/Users/User/esp/esp-idf/components/esp_adc_cal/include -IC:/Users/User/esp/esp-idf/components/esp_hid/include -IC:/Users/User/esp/esp-idf/components/tcp_transport/include -IC:/Users/User/esp/esp-idf/components/esp_http_client/include -IC:/Users/User/esp/esp-idf/components/esp_http_server/include -IC:/Users/User/esp/esp-idf/components/esp_https_ota/include -IC:/Users/User/esp/esp-idf/components/protobuf-c/protobuf-c -IC:/Users/User/esp/esp-idf/components/protocomm/include/common -IC:/Users/User/esp/esp-idf/components/protocomm/include/security -IC:/Users/User/esp/esp-idf/components/protocomm/include/transports -IC:/Users/User/esp/esp-idf/components/mdns/include -IC:/Users/User/esp/esp-idf/components/esp_local_ctrl/include -IC:/Users/User/esp/esp-idf/components/sdmmc/include -IC:/Users/User/esp/esp-idf/components/esp_serial_slave_link/include -IC:/Users/User/esp/esp-idf/components/esp_websocket_client/include -IC:/Users/User/esp/esp-idf/components/expat/expat/expat/lib -IC:/Users/User/esp/esp-idf/components/expat/port/include -IC:/Users/User/esp/esp-idf/components/wear_levelling/include -IC:/Users/User/esp/esp-idf/components/fatfs/diskio -IC:/Users/User/esp/esp-idf/components/fatfs/vfs -IC:/Users/User/esp/esp-idf/components/fatfs/src -IC:/Users/User/esp/esp-idf/components/freemodbus/common/include -IC:/Users/User/esp/esp-idf/components/idf_test/include -IC:/Users/User/esp/esp-idf/components/idf_test/include/esp32 -IC:/Users/User/esp/esp-idf/components/jsmn/include -IC:/Users/User/esp/esp-idf/components/json/cJSON -IC:/Users/User/esp/esp-idf/components/libsodium/libsodium/src/libsodium/include -IC:/Users/User/esp/esp-idf/components/libsodium/port_include -IC:/Users/User/esp/esp-idf/components/mqtt/esp-mqtt/include -IC:/Users/User/esp/esp-idf/components/openssl/include -IC:/Users/User/esp/esp-idf/components/spiffs/include -IC:/Users/User/esp/esp-idf/components/ulp/include -IC:/Users/User/esp/esp-idf/components/wifi_provisioning/include -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -std=gnu++11
-fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.3-dirty\" -DESP_PLATFORM -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\main.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj -c ../main/main.cpp
../main/main.cpp:3:10: fatal error: Metriful_sensor.h: No such file or directory
#include "Metriful_sensor.h"
^~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
最佳答案
您可能会从 CMake 用户那里得到很多答案,但 ESP-IDF 非常不同,以至于很多答案在两者之间不兼容
IDF 使用构建在 CMake 之上的组件模型,因此大多数普通的 include 命令不会执行任何操作
你要看idf_component_register
您可能想将 Metriful 注册为一个新组件,并且由于它依赖于 Arduino,您可能需要一些额外的步骤。
如果你想保留你当前的目录结构,在你的顶部级别 CMake(顶部带有 cmake_minimum_required
的级别)添加行:
set(EXTRA_COMPONENT_DIRS "Metriful")
否则在main
文件夹旁边创建一个名为components
的文件夹,并将Metriful 放入该文件夹中:
- main
main.cpp
your.h
- components
-Metriful
Metriful.cpp
Metriful.h
将 Metriful 注册为 IDF 组件(如果尚未注册)。
检查 Metriful/CMakeList.txt
是否有 idf_component_register
,如果不包含,则将内容替换为
idf_component_register(
SRCS "Metriful/MetrifulC.cpp" "Metriful/MetrifulA.cpp"
INCLUDE_DIRS "."
REQUIRES arduino
)
注意:您需要将Metriful中的每个.cpp
手动添加到这个文件中,与您添加新文件时的main相同
将 Metriful 添加为您的主要要求。在 main/CMakeList.txt
中添加一行到您的 idf_component_register
REQUIRES Metriful
请注意名称 Metriful 将区分大小写并且必须与 Metriful 的文件夹名称相匹配
此时,如果您已经将 Arduino 添加到您的 ESP-IDF 项目中,一切都会正常进行。如果您没有遵循这些说明:https://github.com/espressif/arduino-esp32/blob/master/docs/esp-idf_component.md
还想把它放在那里,Metriful 似乎是一个基于 Arduino 的库。如果您是 ESP32 的新手,直接使用 ESP-IDF 可能会很麻烦,因为您可能会使用很多基于 Arduino 的库。
Arduino 库可在 ESP-IDF 中运行,但在 ESP-IDF 更新时,您通常需要解决不兼容问题。
您有直接使用 ESP-IDF 的特定原因吗?请记住,Platform.IO 可让您生成一个编译数据库,因此如果您需要的话,您可以使用大多数编码环境。
关于c++ - CMakeLists - 如何包含源文件和头文件的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68317455/
我有一个类似于以下的结构。 class A { string title; List bItem; } class B { int pric
本地流 和 远程流 两者都是“媒体流列表 ”。 本地流 包含“本地媒体流 ” 对象 但是,远程流 包含“媒体流 ” 对象 为什么差别这么大? 当我使用“本地流 “- 这个对我有用: localVide
我正在尝试将 8 列虚拟变量转换为 8 级排名的一列。 我试图用这个公式来做到这一点: =IF(OR(A1="1");"1";IF(OR(B1="1");"2";IF(OR(C1="1");"3";I
我正在使用面向对象编程在 Python 中创建一个有点复杂的棋盘游戏的实现。 我的问题是,许多这些对象应该能够与其他对象交互,即使它们不包含在其中。 例如Game是一个对象,其中包含PointTrac
有没有办法获取与 contains 语句匹配的最深元素? 基本上,如果我有嵌套的 div,我想要最后一个元素而不是父元素: Needle $("div:contains('Needle')")
出于某种原因,我无法在 Google 上找到答案!但是使用 SQL contains 函数我怎么能告诉它从字符串的开头开始,即我正在寻找等同于的全文 喜欢 'some_term%'。 我知道我可以使用
我正在尝试创建一个正则表达式来匹配具有 3 个或更多元音的字符串。 我试过这个: [aeiou]{3,} 但它仅在元音按顺序排列时才有效。有什么建议吗? 例如: 塞缪尔 -> 有效 琼 -> 无效 S
嘿所以我遇到了这样的情况,我从数据库中拉回一个客户,并通过包含的方式包含所有案例研究 return (from c in db.Clients.Include("CaseStudies")
如果关键字是子字符串,我无法弄清楚为什么这个函数不返回结果。 const string = 'cake'; const substring = 'cak'; console.log(string.in
我正在尝试将包含特定文本字符串的任何元素更改为红色。在我的示例中,我可以将子元素变为蓝色,但是我编写“替换我”行的方式有些不正确;红色不会发生变化。我注意到“contains”方法通常写为 :cont
我想问一下我是否可以要求/包含一个语法错误的文件,如果不能,则require/include返回一个值,这样我就知道所需/包含的文件存在语法错误并且不能被要求/包含? file.php语法错误 inc
我想为所有包含youtube链接的链接添加一个rel。 这就是我正在使用的东西-但它没有用。有任何想法吗? $('a [href:contains(“youtube.com”)]')。attr('re
我正在尝试在 Elasticsearch 中查询。除搜索中出现“/”外,此功能均正常运行。查询如下所示 GET styling_rules/product_line_filters/_search {
我正在开发名为eBookRepository的ASP.NET MVC应用程序,其中包含在线图书。 电子书具有自己的标题,作者等。因此,现在我正在尝试实现搜索机制。我必须使用Elasticsearch作
我已阅读Firebase Documentation并且不明白什么是 .contains()。 以下是文档中 Firebase 数据库的示例规则: { "rules": { "rooms"
我的问题是我可以给出条件[ 'BookTitleMaster.id' => $xtitid, ] 如下所示 $bbookinfs = $this->BookStockin->BookIssue->fi
我需要能够使用 | 检查模式在他们中。例如,对于像“dtest|test”这样的字符串,像 d*|*t 这样的表达式应该返回 true。 我不是正则表达式英雄,所以我只是尝试了一些事情,例如: Reg
我想创建一个正则表达式来不匹配某些单词... 我的字符:var test = "é123rr;and;ià456;or;456543" 我的正则表达式:test.match(\((?!and)(?!o
我在 XSLT 中有一个名为 variable_name 的变量,如果相关产品具有名称为 A 或 B 或两者均为 A & 的属性,我将尝试将其设置为 1 B.
您好,我想让接待员和经理能够查看工作类型和费率并随后进行更新。但是技术人员只能查看不能更新。该图是否有效? 我读到扩展用例是由发起基本用例的参与者发起的。我应该如何区分技术人员只能启动基本案例而不能启
我是一名优秀的程序员,十分优秀!