A guide on how to add a component into a project

Amir_El
Posts: 17
Joined: Thu Nov 19, 2020 3:55 pm

A guide on how to add a component into a project

Postby Amir_El » Wed Jul 21, 2021 2:00 pm

Hello everyone, i would like to include this LoRaWAN Component in my projecthttps://github.com/TobleMiner/lmic-esp-idf but I always get a compilation error. Could someone kindly, guide me to how to include the library (what modification I should do in the CMake file and where is the directory should be) or give me a link to a source that explain this.


Thank you

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: A guide on how to add a component into a project

Postby mbratch » Thu Jul 22, 2021 1:59 am

Did you clone the library into the components subdirectory of your project?
What is your project structure?
What compile errors are you getting?

Amir_El
Posts: 17
Joined: Thu Nov 19, 2020 3:55 pm

Re: A guide on how to add a component into a project

Postby Amir_El » Thu Jul 22, 2021 3:10 pm

Hi, thank you for your replay.....

I copy it into a folder that I created inside the "main" folder and add the line

Code: Select all

idf_component_register(SRCS

        "main.c"
        
        INCLUDE_DIRS 
        "."
        "./Lib/LoRaWAN"
        )
To the CMake file inside the main folder.

my project structure is like

Image

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: A guide on how to add a component into a project

Postby fasani » Sun Aug 15, 2021 6:11 am

Please read the Build system documentation part specifically where it specifies what is the right directory structure:
https://docs.espressif.com/projects/esp ... le-project

Code: Select all

myProject/
             - CMakeLists.txt
             - sdkconfig
             - components/ - component1/ - CMakeLists.txt
                                         - Kconfig
                                         - src1.c
                           - component2/ - CMakeLists.txt
                                         - Kconfig
                                         - src1.c
                                         - include/ - component2.h
             - main/       - CMakeLists.txt
                           - src1.c
                           - src2.c

             - build/
             
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

Amir_El
Posts: 17
Joined: Thu Nov 19, 2020 3:55 pm

Re: A guide on how to add a component into a project

Postby Amir_El » Tue Aug 24, 2021 6:44 pm

Thank you for sharing this. I modified the directories as it's shown but I'm still struggling to register the component.


This is My Top Level CMakeLists:

Image

This is the inside main folder CMakeLists
Image

This is the Inside the LoRaWAN component folder CmakeLists file
Image


please help

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: A guide on how to add a component into a project

Postby fasani » Sat Sep 18, 2021 6:35 am

First of all, I see you didn’t read the Build system like I recommended and just focused to solve the problem.
But sometimes you need to put the problem aside and read documentation in order to come with a proper solution.

Also the error is clearly indicating that the component is not found in that directory. I guess at this point so long after your post you should have solve this anyways. Best!
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

Who is online

Users browsing this forum: No registered users and 171 guests