adding lib to component trouble

zheckiss
Posts: 3
Joined: Thu Dec 22, 2022 8:15 am

adding lib to component trouble

Postby zheckiss » Wed Jul 09, 2025 3:35 am

Hi! I have component folder in my project It contains espressif__libpng, joltwallet__littlefs, lvgl__lvgl folders. I need to make libpng and littlefs to be visible for lvgl because cmake error:
Compilation failed because lv_libpng.c (in "lvgl__lvgl" component) includes png.h, provided by espressif__libpng component(s).
However, espressif__libpng component(s) is not in the requirements list of "lvgl__lvgl".
To fix this, add espressif__libpng to PRIV_REQUIRES list of idf_component_register call in D:\project\ESP32S3\MFM_01\components\lvgl__lvgl\CMakeLists.txt.
When I add

Code: Select all

idf_component_register(
    PRIV_REQUIRES 
        libpng )
to cmakelists.txt of lvgl folder I receive the next error:
CMake Error at C:/Users/malkov/esp/v5.3.1/esp-idf/tools/cmake/component.cmake:488 (add_library):
add_library cannot create target "__idf_lvgl__lvgl" because another target
with the same name already exists. The existing target is a static library
created in source directory
"D:/project/ESP32S3/MFM_01/components/lvgl__lvgl". See documentation for
policy CMP0002 for more details.
Call Stack (most recent call first):
components/lvgl__lvgl/CMakeLists.txt:42 (idf_component_register)
please help me how to fix this?

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: adding lib to component trouble

Postby MicroController » Thu Jul 10, 2025 9:27 am

To fix this, add espressif__libpng to PRIV_REQUIRES list of idf_component_register call in D:\project\ESP32S3\MFM_01\components\lvgl__lvgl\CMakeLists.txt.
Just do what it says.
Open the CMakeLists.txt and add the PRIV_REQUIRES to the existing call to idf_component_register().

frhr
Espressif staff
Espressif staff
Posts: 12
Joined: Tue Jan 10, 2023 10:41 am

Re: adding lib to component trouble

Postby frhr » Thu Jul 10, 2025 10:17 am

Hello,

as MicroController already stated the dependency needs to be added to the lvgl cmake component registration.

I tried with hello_world project
  • $ idf.py add-dependency "espressif/libpng^1.6.39~1"
  • $ idf.py add-dependency "lvgl/lvgl^9.3.0"
  • $ idf.py menuconfig # Component config ---> LVGL configuration ---> 3rd Party Libraries ---> [x] PNG decoder(libpng) library
  • $ vim managed_components/lvgl__lvgl/env_support/cmake/esp.cmake

Code: Select all

  idf_component_register(SRCS ${SOURCES} ${EXAMPLE_SOURCES} ${DEMO_SOURCES}
      INCLUDE_DIRS ${LVGL_ROOT_DIR} ${LVGL_ROOT_DIR}/src ${LVGL_ROOT_DIR}/../
                   ${LVGL_ROOT_DIR}/examples ${LVGL_ROOT_DIR}/demos
      PRIV_REQUIRES espressif__libpng
      REQUIRES esp_timer)
HTH

User avatar
Mephisto75
Posts: 5
Joined: Wed Aug 17, 2022 2:23 pm

Re: adding lib to component trouble

Postby Mephisto75 » Sun Feb 08, 2026 2:31 pm

Hey, everyone,

I am having a few issues myself and therefore need you help!
Can you confirm that you were able to install 'espressif__libpng'?

Code: Select all

idf.py add-dependency "espressif/libpng^1.6.39~1" 
will change the idf_component.yml but no matter what I do I can't get it to download espressif__ligpng into the managed_components folder.

I even deleted the build folder and tried

Code: Select all

idf.py reconfigure
to download any missing parts, but still nothing.
Since you guys are obviously one step ahead, can you give a hint on how to install the component?

Many Thanks!

nopnop2002
Posts: 347
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: adding lib to component trouble

Postby nopnop2002 » Mon Feb 09, 2026 3:14 am

Create idf_component.yml in main directory.

Code: Select all

## IDF Component Manager Manifest File
dependencies:
  espressif/libpng:
    version: "^1.6.39"
Execute command.

Code: Select all

$ idf.py fullclean
$ rm dependencies.lock
$ idf.py build
$ ls -l managed_components/
total 8
drwxrwxr-x 4 nop nop 4096 Feb  9 12:15 espressif__libpng
drwxrwxr-x 4 nop nop 4096 Feb  9 12:15 espressif__zlib

Who is online

Users browsing this forum: Bing [Bot], nopnop2002, Qwantbot, Semrush [Bot] and 4 guests