Creating my own library

leenowell
Posts: 162
Joined: Tue Jan 15, 2019 1:50 pm

Creating my own library

Postby leenowell » Tue Dec 30, 2025 8:45 am

Hi All,

I have a few projects on the go and have created a number of functions that are common to them all. I am looking to create a common library for them and then use this library in my other projects. I have searched around but can't find any instructions on how to create the library and then how to add it into an ESP32 project. I am using the VSCode IDE and extension so how to do it in that would be ideal but can do it outside of it if needed.

Many thanks in advance

Lee.

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

Re: Creating my own library

Postby nopnop2002 » Tue Dec 30, 2025 11:44 pm

You can use EXTRA_COMPONENT_DIRS in CMakeLists.txt.

Here's an example.

https://github.com/nopnop2002/esp-idf-s ... sts.txt#L5

leenowell
Posts: 162
Joined: Tue Jan 15, 2019 1:50 pm

Re: Creating my own library

Postby leenowell » Wed Dec 31, 2025 12:15 pm

Thanks very much for getting back to me. I think this would include the component source and header files directly rather than create a binary that I could link into my project (e.g. a ".o" or ".a")? Is there a way of linking a pre-built binary or maybe this is how the ESP setup works?

Many thanks

Lee.

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

Re: Creating my own library

Postby nopnop2002 » Wed Dec 31, 2025 1:39 pm


leenowell
Posts: 162
Joined: Tue Jan 15, 2019 1:50 pm

Re: Creating my own library

Postby leenowell » Wed Dec 31, 2025 1:58 pm

Fantastic thanks very much for your help will give it a go.

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

Re: Creating my own library

Postby MicroController » Wed Dec 31, 2025 5:48 pm

or maybe this is how the ESP setup works?
It most commonly is. One reason is that you often want the library/component to be configurable via Kconfig/menuconfig; another one is support for different SoCs, which a pre-built library may not be able to offer easily.

leenowell
Posts: 162
Joined: Tue Jan 15, 2019 1:50 pm

Re: Creating my own library

Postby leenowell » Thu Jan 01, 2026 12:25 pm

Thanks for replying @MicroController. Very good points thanks very much.

Who is online

Users browsing this forum: ChatGPT-User, Qwantbot, YisouSpider and 9 guests