Create Makefile for external library


I am using RUT240 as IoT Router and want to receive MQTT message from Azure IoT Hub. For that reason, I use Azure IoT Hub C SDK from Microsoft. I am totally a newbie with OpenWrt and therefore, I started with "Hello world" for OpenWrt and did it successfully.

But for complicated library like Azure IoT Hub C SDK, I did the same steps and receive error:

I guess, I have to include the library in Makefile but I don't know how. Please give me some advices.

Thanks in advance.

If it's a shared library, and you want to do it "right", you need to package it separately and then add it as a dependency to your project.

Thank you andyboeh but I don't get your idea. Do you mean, I should create binary file (*.ipk) of every single library and install it?
I created a binary file from the example of Azure for Debian without package library to binary file. So, I guess for OpenWrt it should work the same.

If it's a shared library, then yes. Other packages can then depend on it, reducing the needed space. I don't know if that's possible or wanted with your particular application.

I use the library for my particular application, no more than that. So it is better, if all the library and application stay in one binary file. :roll_eyes:

OK, so it's not a shared library :slight_smile: Then you need to edit the Makefile or CMakeLists.txt to build all required source files.

1 Like

Yes, that is my question. How could all the library be included in Makefile or CMakeLists.txt? I mean, I did the "helloworld" example but they didn't use any lib.

In this case you just add the individual source files. This is standard software project management and not OpenWrt-specific. Please research how to add new source files to a project.

1 Like