Linking Issues when restructuring components

_anton_
Posts: 1
Joined: Tue Nov 05, 2024 11:08 am

Linking Issues when restructuring components

Postby _anton_ » Tue Nov 05, 2024 11:10 am

Hi, I have the following problems when restructuring my components:
I have a component A, which is local to a project (it is in the projects "components" folder).
Then I have a folder X on my PC, where all shared components are.
Component A uses multiple components from this folder X, let's call them B and C.
There is also a component D in this folder X, which is not used in the project, yet still included when compiling it (I have not fully understood why, but all components from the folder X seem to be compiled
with the project, regardless of whether they appear in some "(PRIV_)Requires" clause or not).
D requires (public) a component E (which is in folder X), which is also used in B and C (private requires).
When setting the Requires clause in D for component E to PRIV_Requires, linking of the project fails, since A cannot find functions from B and C anymore.
I tried debugging this for hours, but no result.
I have no idea why component D is even relevant in this project or why functions from B and C are influenced by the public requires of E...
Furthermore, when I include D as a managed component (via a git repository, which I want to replace the folder on my PC with), linking fails as well, with E being publically required.
If I then move D from the managed_components folder to the local components folder of the project, it works.
Can somebody give me a hint on how I can debug this issue?

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Linking Issues when restructuring components

Postby chegewara » Thu Nov 07, 2024 12:55 pm

When your project is using functions from component which is included with PRIV_REQUIRED in another component then you have to include that components in CMakeLists.txt too. Its easier and safe to include in your components with REQUIRED or PRIV_REQUIRED all components on which your component is dependent.

If you are using components registry too, then you can add idf_component.yml in your components, which will point to required components in registry.

Who is online

Users browsing this forum: No registered users and 195 guests