Page 1 of 1

esp-idf v4.1 SDK使用cjson时编译报错

Posted: Tue Mar 09, 2021 9:50 am
by lxdemon
你好,最近准备从ESP-IDF V3.3迁移到V4.1,现在添加了cJSON后,工程编译不过去,我查看了SDK中是有这个component的,我在工程中也添加了头文件,但不知道为何编译不过去,麻烦帮忙看一下是什么问题,万分感激!

附上报错log:
../components/tcp_handle/tcp_handle.c:22:10: fatal error: cJSON.h: No such file or directory
#include "cJSON.h"
^~~~~~~~~
compilation terminated.
[5/12] Building C object esp-idf/components/CMakeFiles/__idf_components.dir/ir_handle/app_ir_tx.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Re: esp-idf v4.1 SDK使用cjson时编译报错

Posted: Thu Mar 18, 2021 9:21 am
by ESP_Gargamel
有观察到你自己建立了一个 tcp_handle 的 component,这个 component 有对其他 component 的依赖,比如你的 case 中需要使用 json 这个 component,请参看:https://docs.espressif.com/projects/esp ... uires#id27,依据此,你需要修改 tcp_handle 下的 CMakeLists.txt,修改成类似:
idf_component_register(...
REQUIRES json)
具体 REQUIRES 和 PRIV_REQUIRES 请参看文档说明使用。