Legato and third party libraries FX30s

Hello!

I have a question about how Legato apps work. that apps can have third party libraries (for example PahoMQTT)? I tried to add that library several times but the program crashes.

I add the libraries at some parts to the code:

MQTT_pruebaComponent.c
"
#include “MQTTClient.h”
"

Component.cdef
"
sources:
{
//The component that has the c program
MQTT_pruebaComponent.c
}

cflags:
{
//this folder has MQTTAsync.h, MQTTClient.h and MQTTClientPersistence.h
-I $CURDIR/…/Librerias
}
"

Console logs:
"
08:59:11 **** Incremental Build of configuration Target_Legato_Debug for project MQTT_prueba ****
make: Entering directory ‘C:\Legato\workspace\MQTT_prueba/Target_Legato_Debug’
cd …;mkapp -t wp750x -o /tmp/build/MQTT_prueba/Target_Legato_Debug -w /tmp/build/MQTT_prueba/Target_Legato_Debug -i “/legato/interfaces” -i “/legato/interfaces/wifi” -i “/legato/interfaces/atServices” -i “/legato/interfaces/supervisor” -i “/legato/interfaces/logDaemon” -i “/legato/interfaces/airVantage” -i “/legato/interfaces/secureStorage” -i “/legato/interfaces/positioning” -i “/legato/interfaces/modemServices” -i “C:\Users\USUARIO\Desktop\librerias” -s “/legato/components/fwupdate/platformAdaptor/default” -s “.” -s “/legato/modules/WiFi/service” -s “/legato/components/airVantage/platformAdaptor/default” -s “/legato/components/airVantage” -s “/legato/components/fwupdate” -s “/legato/modules/WiFi/apps/tools/wifi” -s “/legato/components/positioning/platformAdaptor/default” -s “/legato/components/positioning” -s “/legato/components/devMode” -s “/legato/components/secStore/platformAdaptor/default” -s “/legato/components/secStore” -s “/legato/components/uartMode/platformAdaptor/default” -s “/legato/components/modemServices/platformAdaptor/default” -s “/legato/components/atServices” -s “/legato/components/modemServices” -s “/legato/components” -s “/legato/components/uartMode” -s “/legato/components/audio/platformAdaptor/default” -s “/legato/apps/tools” -C -g -X -g -L -g MQTT_prueba.adef
[1/7] Compiling C source
[2/7] Compiling C source
[3/7] Linking C library
[4/7] Creating hard link
[5/7] Linking C executable
make: *** [target] Error 1
FAILED: /opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y17-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -o /tmp/build/MQTT_prueba/Target_Legato_Debug/app/MQTT_prueba/staging/read-only/bin/mqtt_prueba /tmp/build/MQTT_prueba/Target_Legato_Debug/app/MQTT_prueba/obj/mqtt_prueba/_main.c.o -rdynamic -Wl,–enable-new-dtags,-rpath=“$ORIGIN/…/lib” -L/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib “-L/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib” -lComponent_MQTT_pruebaComponent “-L/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib” -lComponent_MQTT_pruebaComponent “-L$LEGATO_BUILD/framework/lib” -llegato -lpthread -lrt -ldl -lm -g
/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference to MQTTClient_disconnect’ /tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference toMQTTClient_publishMessage’
/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference to MQTTClient_connect’ /tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference toMQTTClient_destroy’
/tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference to MQTTClient_waitForCompletion’ /tmp/build/MQTT_prueba/Target_Legato_Debug/staging/read-only/lib/libComponent_MQTT_pruebaComponent.so: undefined reference toMQTTClient_create’
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Makefile:44: recipe for target ‘target’ failed
make: Leaving directory ‘C:\Legato\workspace\MQTT_prueba/Target_Legato_Debug’

08:59:14 Build Finished (took 3s.518ms)
"

In some places i see that people uses .so files, but when I try to use them inside “ldflags” at Component.cdef, the error is “C:\Legato\workspace\MQTT_prueba/MQTT_pruebaComponent/…/Librerias/libpaho-mqtt3a.so: file not recognized: File format not recognized”.

Regards,

Pablo

Hi Pablo
I can see that you raised another topic which could be linked to this one and which is solved

are you still waiting for any feedback from the current topic?

onto Legato.io there is a page on how to add a third-party library
Add 3rd Party Files - Legato Docs

Regards