After downloading and building the ESP32 repository for Linux (I am running elementary OS 4.0 Juno), I've encountered a problem where I can't invoke anything to do with `idf.py`. I can't call `menuconfig`, or flash/monitor examples. I consistently get the error:
```
CMake error at main/CMakeLists.txt:1 (idf_component_register):
Unknown CMake command "idf_component_register
```
If I google the problem, I get this one github thread here: https://github.com/espressif/esp-idf/issues/3741
And the user in question "solved" his problem (which isn't entirely the same as mine) by refactoring his code into fewer files. In any case, it doesn't reapply apply since he has a different issue (he can use menuconfig sometimes) and the solution isn't ideal.
Can anyone explain to me how to solve this problem?
Encountering unknown CMake command "idf_component_register"
Re: Encountering unknown CMake command "idf_component_register"
Hi Micrified,
What version of ESP-IDF do you have? "idf_component_register" was only added in ESP-IDF V4.0 so older versions use different syntax. The IDF Programming Guide that matches the version you are using should have the correct syntax.
If this isn't the problem, can you please post the full output from running idf.py against one of the included examples?
Thanks,
Angus
What version of ESP-IDF do you have? "idf_component_register" was only added in ESP-IDF V4.0 so older versions use different syntax. The IDF Programming Guide that matches the version you are using should have the correct syntax.
If this isn't the problem, can you please post the full output from running idf.py against one of the included examples?
Thanks,
Angus
Re: Encountering unknown CMake command "idf_component_register"
Hello. Let me explain what I did to install it. I in fact went right back through the procedure to make sure:
1. I first began by installing the standard toolchain for Linux. The guide I link here is what I followed: https://docs.espressif.com/projects/esp ... setup.html.
I installed it for 64-bit Linux. Everything is fine. I unzipped the toolchain to the recommended directory at ~/esp.
My shell profile currently looks as follows after modifying it:
[Codebox]
export IDF_PATH=~/esp/esp-idf
export PATH=~/esp/xtensa-esp32-elf/bin:$PATH
[/Codebox]
2. I continued with the rest of the guide here: https://docs.espressif.com/projects/esp ... et-esp-idf to get the ESP repository. This was just fine.
3. I added the tools to the path using: . add_path.sh
In my personal project, I encounter the same error I described as before if I invoke: idf.py build
[Codebox]
Came Error at main/CMakeLists.txt:1 (idf_component_register):
Unknown CMake command "idf_component_register".
[/Codebox]
Of course, the guide is using make instead. If I try to compile my program with make, then it works, but I get errors that don't exist on my Linux workstation at home (this isn't compiling on a Linux laptop). For instance:
[Codebox]
/home/micrified/esp/esp32-wifi/build/libmain.a(esp32_wifi_main.o):(.literal.app_main+0x14): undefined reference to `ble_init`
[/Codebox]
This doesn't make any sense, because (well it works on another workstation) and the header defining that function is clearly accessible and reachable:
Project Structure:
[Codebox]
- main
| - include
| | - ble.h
| | - ble_profiles.h
| | - wifi.h
| - src
| | - ble.c
| | - wifi.c
- CMakeLists.txt
- component.mk
- esp_32_wifi_main.c
[/Codebox]
(These files are very small)
See esp_32_wifi_main.c here: https://gist.github.com/Micrified/ec855 ... 08e5b92766
See ble.h here: https://gist.github.com/Micrified/4f9e9 ... 67ffe66aa0
See ble.c here:https://gist.github.com/Micrified/0145a ... 0e4aeeee03
If you can help me figure out what on Earth is going on I'd be very grateful.
1. I first began by installing the standard toolchain for Linux. The guide I link here is what I followed: https://docs.espressif.com/projects/esp ... setup.html.
I installed it for 64-bit Linux. Everything is fine. I unzipped the toolchain to the recommended directory at ~/esp.
My shell profile currently looks as follows after modifying it:
[Codebox]
export IDF_PATH=~/esp/esp-idf
export PATH=~/esp/xtensa-esp32-elf/bin:$PATH
[/Codebox]
2. I continued with the rest of the guide here: https://docs.espressif.com/projects/esp ... et-esp-idf to get the ESP repository. This was just fine.
3. I added the tools to the path using: . add_path.sh
In my personal project, I encounter the same error I described as before if I invoke: idf.py build
[Codebox]
Came Error at main/CMakeLists.txt:1 (idf_component_register):
Unknown CMake command "idf_component_register".
[/Codebox]
Of course, the guide is using make instead. If I try to compile my program with make, then it works, but I get errors that don't exist on my Linux workstation at home (this isn't compiling on a Linux laptop). For instance:
[Codebox]
/home/micrified/esp/esp32-wifi/build/libmain.a(esp32_wifi_main.o):(.literal.app_main+0x14): undefined reference to `ble_init`
[/Codebox]
This doesn't make any sense, because (well it works on another workstation) and the header defining that function is clearly accessible and reachable:
Project Structure:
[Codebox]
- main
| - include
| | - ble.h
| | - ble_profiles.h
| | - wifi.h
| - src
| | - ble.c
| | - wifi.c
- CMakeLists.txt
- component.mk
- esp_32_wifi_main.c
[/Codebox]
(These files are very small)
See esp_32_wifi_main.c here: https://gist.github.com/Micrified/ec855 ... 08e5b92766
See ble.h here: https://gist.github.com/Micrified/4f9e9 ... 67ffe66aa0
See ble.c here:https://gist.github.com/Micrified/0145a ... 0e4aeeee03
If you can help me figure out what on Earth is going on I'd be very grateful.
Micrified (Netherlands)
Re: Encountering unknown CMake command "idf_component_register"
Thanks. This solved it for me. I was cloning the wrong branch. V4.0 > (latest) is required.Hi Micrified,
What version of ESP-IDF do you have? "idf_component_register" was only added in ESP-IDF V4.0 so older versions use different syntax. The IDF Programming Guide that matches the version you are using should have the correct syntax.
If this isn't the problem, can you please post the full output from running idf.py against one of the included examples?
Thanks,
Angus
-
akhilaki46784
- Posts: 1
- Joined: Wed Jun 16, 2021 4:42 pm
Re: Encountering unknown CMake command "idf_component_register"
change idf_component_register() in CMakeLists.txt to register_component().
Now try "idf.py build"
Now try "idf.py build"
-
Germanunkol
- Posts: 3
- Joined: Sun Aug 21, 2022 6:27 pm
Re: Encountering unknown CMake command "idf_component_register"
Sorry for re-opening this old thread, but I found it while having the same error:
It can also happen if you're trying to build in the wrong folder. In my case, I was calling inside the component folder instead of its parent. Switching to the correct folder before building solves the issue.
It can also happen if you're trying to build in the wrong folder. In my case, I was calling
Code: Select all
idf.py buildRe: Encountering unknown CMake command "idf_component_register"
I has a similar problem, that was fixed by... not doing the build in that directory, but in the main project directory.
The below error was happening on a "library" module, where I tried to do idf.py build, receiving
The solution for me was to go to the main directory of the project and directly do idf.py build there, after removing the ./build temporary directory. The project correctly used the dependencies without doing any build for the libraries.
Before finding this solution I searched a lot and found this post. Hope this helps people like me, not sure if all have my issue.
For the reference:
- my project directory where
- the error was happening on M5_Camera_Examples/common/i2c_manager - running build here was not needed actually
- I used this for my project to work:
Note: I am noob to this build system, I cannot explain at this moment why this works like this.
The below error was happening on a "library" module, where I tried to do idf.py build, receiving
Code: Untitled.txt Select all
CMake Error at CMakeLists.txt:9 (idf_component_register):
Unknown CMake command "idf_component_register".Before finding this solution I searched a lot and found this post. Hope this helps people like me, not sure if all have my issue.
For the reference:
- my project directory where
worked was: M5_Camera_Examples/idf/SMB-PUTidf.py build
- the error was happening on M5_Camera_Examples/common/i2c_manager - running build here was not needed actually
- I used this for my project to work:
idf.py --version
P.S. It helped to remove the ./build temporary directory before the build - in the main directory of the project.ESP-IDF v4.4.7
Note: I am noob to this build system, I cannot explain at this moment why this works like this.
Who is online
Users browsing this forum: ChatGPT-User, Google [Bot], PerplexityBot, PetalBot, Qwantbot, Semrush [Bot] and 11 guests
