Page 1 of 1

求帮助,关于工程中components组件的问题

Posted: Mon Aug 12, 2019 2:44 am
by lucx325
请教各位,我最近刚刚学习esp32,关于component组件怎么使用遇到问题,我创建了一个project, 里面的main直接拷贝的idf里面的example/get_start/hello_world, 让我我在components里面创建了一个wifi文件夹,直接拷贝的example里面的wifi/getting_started/station/main的文件,然后在helloworld源文件里面调用wifi源文件的函数,来连接我自己的wifi,但是使用idf.py build的时候出现components/wifi/station_example_main.c:17:23: fatal error: nvs_flash.h: No such file or directory compilation terminated. wifi文件夹下面的CMakeLists.txt内容如下set(COMPONENT_SRCS "station_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS ".")

register_component(), 请问怎么解决这个问题。

Re: 求帮助,关于工程中components组件的问题

Posted: Tue Aug 13, 2019 6:14 am
by ESP_Dazz
建议你直接将 station_example_main.c 拷到 get_started/hello_world/main 里,然后在 hello_world_main.c 里用 extern 声明所有在 station_example_main.c 被使用的函数。

如果你要自己创建一个 components/wifi/ ,你就要用 idf_component_register() 的 REQUIRES 指定这个 component 依靠了另外那一些 component,例如 nvs_flash。请看看 components/driver/CMakeLists.txt 作为例子。

Re: 求帮助,关于工程中components组件的问题

Posted: Tue Aug 13, 2019 8:50 am
by lucx325
好的,谢谢,我把components/wifi里的CMackeLists.txt通过set(COMPONENT_ADD_INCLUDEDIRS )把WiFi所需的头文件添加了也编译通过了。