How to use CMake in ESP_IDF projects with components?

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

How to use CMake in ESP_IDF projects with components?

Postby MickPF » Sat May 08, 2021 5:07 pm

Hello,

I recently started using esp_idf 4.4 with cmake instead of make. I am an absolute beginner with using cmake and therefore have problems with it.

I have 2 components in a project ("ft813" and "gfx") and of course the "main" module. "main" calls "gfx", and "gfx" calls "ft813".

When I execute "idf.py build" I always get the following error message at the end:

Code: Select all

/opt/esp32/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/gfx/libgfx.a(gfx.c.obj):(.literal.gfx_init+0x0): undefined reference to `ft813_init'
/opt/esp32/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/gfx/libgfx.a(gfx.c.obj): in function `gfx_init':
/home/mick/Projects/ESP32/ft813/build/../components/gfx/gfx.c:27: undefined reference to `ft813_init'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
I've placed the whole compiler output in the attachment.

This is due to the order of the modules as they are passed to the linker. I've played with the entry "COMPONENT_REQUIRES" in the files "CMakeLists.txt" in "main" and "gfx", but it doesn't change anything.

I've tried unsuccessfully to find these informations in the ESP_IDF documentation and in the ES_IDF examples.

Can someone please show me how to do it right?

Thanks in advance,
Michael
Attachments
compiler_output.log
CMake output
(144.15 KiB) Downloaded 509 times
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

Re: How to use CMake in ESP_IDF projects with components?

Postby MickPF » Sun May 09, 2021 8:34 am

I found a solution in the thread 'How to create "complex" project structures ?' (https://www.esp32.com/viewtopic.php?f=13&t=12206).
It works now.
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

Who is online

Users browsing this forum: Google [Bot] and 137 guests