Page 1 of 3

building a 3rd party library

Posted: Tue Jun 16, 2020 10:31 pm
by mzimmers
Hi all -

I need to build some source from a 3rd party (https://github.com/cisco/libsrtp). I added a line in the main/CMakeLists.txt file to use the IDF project.cmake file. I then ran "idf.py build" and it built...but it built for a Windows platform.

I really don't know anything about cmake. Can someone please give me an idea of what I need to do to point to the xtensa toolchain and build a library for the ESP32?

Thank you.

Re: building a 3rd party library

Posted: Tue Jun 16, 2020 11:56 pm
by ESP_renz
Can you give us a snippet of how you are including the third-party project? The behavior you are seeing is weird, since the top-level project should dictate the target and toolchain.

Re: building a 3rd party library

Posted: Wed Jun 17, 2020 12:02 am
by mzimmers
Hi renz - I'm not trying to include the library yet; I'm just trying to build it. I took the code straight off of gitsrv, and added the one line to the CMakeFiles.txt file, and ran idf.py.

I'm assuming it's appropriate to build the library first, then link to it. Do you think there's a better way to do this?

Thanks...

Re: building a 3rd party library

Posted: Thu Jun 18, 2020 2:33 pm
by mzimmers
BTT...anyone have any advice here?

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 4:53 am
by nvannote
mzimmers wrote:
Thu Jun 18, 2020 2:33 pm
BTT...anyone have any advice here?

Did you create a fresh ESP-IDF project and attempt to drop it in as a project local component? I don't know anything about your situation or the library you're looking to integrate with; but that's where I would start, especially if the code has never been built for a ESP32 before.

Best Regards

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 4:57 am
by mzimmers
It doesn't sound like you're describing building a library -- maybe I'm misunderstanding something.

Do any of the examples show how to build a library? I'd really like to start with that.

Thanks...

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 5:19 am
by nvannote
mzimmers wrote:
Fri Jun 19, 2020 4:57 am
It doesn't sound like you're describing building a library -- maybe I'm misunderstanding something.

What is known as a "component" in the ESP-IDF world, is actually a library and typically the easiest to get going if the code base is not huge (with a lot of it's own configuration).

An example that does not use the component directory method is at: esp-idf/examples/build_system/cmake/import_lib

Perhaps that's what you're looking for?

Best Regards

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 5:51 am
by fasani
I think here there is a misunderstanding of the concepts on how to build something. It took me a while to get it right too, since I started with the Arduino framework and PlatformIO as IDE, and that's a bit a different world.

IDF way as I see it is described here:
Build system
https://docs.espressif.com/projects/esp ... ystem.html

That's a very important point to understand. You don't build a library and then link to it, you build an entire project where that library is part of your project. And that get's built with the IDF toolchain (CMake) and this process generates at the end a binary, plus a bootloader, that is uploaded in the right location to your ESP32.
It does not matter if you call it library or component, but the idea, is that lives in your project and every component has its CMakeFiles. For example in this project I have a epaper library, and a graphics library (Adafruit GFX), everyone has it's folder but they are working together:
https://github.com/martinberlin/cale-id ... components

The idea is that at the end, this components can be git submodules, so you can just fetch it from a repository. But I like to keep it all together to develop a bit faster, without the need to update remote repositories.
It took me at least some weeks to grasp the concept. But once it starts working for you is a nice way to build stuff.

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 6:11 am
by nvannote
Thanks fasani, Correct; You went far further explaining it than I.

Everything is a library/component in the IDF build framework; including the "application" and the various freeRTOS and IDF bits.

What I was trying to point out is that a projects local components directory is (usually) the "path of least resistance" when dealing with *new* third-party library code. But again, that is a bit of an unknown in this thread.

Best Regards

Re: building a 3rd party library

Posted: Fri Jun 19, 2020 4:20 pm
by mzimmers
Thank you both. If I understand correctly, the term "library" as used in the ESP world doesn't refer to a pre-built .a file, but rather a collection of sources and build instructions.

So, if I begin with, say, the Wifi example in the IDF, where in that directory structure should I place the code for the srtplib?

Thanks...