How to Add .so (shared-object library) created in duo-sdk to the duo-sdk to use it?

All, I ported a C++ SSD1306 library from Raspberry Pi to the Milkv-Duo removing the I2C backend based on the Broadcom bcm2835 library to simply use i2c-smbus and ioctl. I can build the SSD1306 OLED library in the duo-sdk resulting in the shared-object library:

libssd1306_rpi.so -> libssd1306_rpi.so.1.0
libssd1306_rpi.so.1 -> libssd1306_rpi.so.1.0
libssd1306_rpi.so.1.0

Now, how do I add this library to the duo-sdk so I can build against it? Looking, the header files look like they should end up under duo-sdk/rootfs/usr/include and the library should end up under duo-sdk/rootfs/usr/lib but then how to tell the build environment that they are there?

On a normal Linux setup, you could simply install the headers, install the lib and run ldconfig to update the shared-object cache. However, the buildroot has no similar tool.

Do I have to build an entire new image and then a new duo-sdk just to add the library? It seems like there should be a simple way to add it to the sdk and then just add it to the existing duo-image on the duo?

What say the experts on how you use a library you have built with the duo?

========= Update =========

It appears it will work in just that fashion. The Makefiles must be updated to reflect the build environment TOOLCHAIN_PREFIX and SYSROOT locations, but after that, building the library and then building the examples against it in the duo-sdk appear to work fine. The only catch is that the environment -mabi=lp64d cannot be used if calling the toolchain version of ld directly, e,g,

.../duo-sdk/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-ld: unrecognised emulation mode: abi=lp64d

Simple calling g++ to invoke the link works fine.

installing the library and symlinks and then headers in the duo-sdk allows building against the library in the duo-sdk.

I also copied the library and symlinks to the duo in /usr/lib as well for running on the duo.

(double check any Makefiles called from your main Makefile to ensure they are also updated with the TOOLCHAIN_PREFIX and SYSROOT)

2 Likes