building a 3rd party library

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

building a 3rd party library

Postby mzimmers » Tue Jun 16, 2020 10:31 pm

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.

ESP_renz
Posts: 18
Joined: Tue May 14, 2019 2:41 am

Re: building a 3rd party library

Postby ESP_renz » Tue Jun 16, 2020 11:56 pm

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.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: building a 3rd party library

Postby mzimmers » Wed Jun 17, 2020 12:02 am

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...

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: building a 3rd party library

Postby mzimmers » Thu Jun 18, 2020 2:33 pm

BTT...anyone have any advice here?

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: building a 3rd party library

Postby nvannote » Fri Jun 19, 2020 4:53 am

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

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: building a 3rd party library

Postby mzimmers » Fri Jun 19, 2020 4:57 am

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...

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: building a 3rd party library

Postby nvannote » Fri Jun 19, 2020 5:19 am

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

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

Re: building a 3rd party library

Postby fasani » Fri Jun 19, 2020 5:51 am

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.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: building a 3rd party library

Postby nvannote » Fri Jun 19, 2020 6:11 am

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

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: building a 3rd party library

Postby mzimmers » Fri Jun 19, 2020 4:20 pm

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...

Who is online

Users browsing this forum: No registered users and 224 guests