# Legato and third party libraries FX30s

**URL:** <https://forum.legato.io/t/legato-and-third-party-libraries-fx30s/3263>\
**Category:** Uncategorized\
**Created:** [May 8, 2018, 6:07pm UTC](https://forum.legato.io/t/legato-and-third-party-libraries-fx30s/3263 "2018-05-08T18:07:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![baiticpruebas](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@baiticpruebas](https://forum.legato.io/u/baiticpruebas)\
**Post date:** [May 8, 2018, 6:07pm UTC](https://forum.legato.io/t/legato-and-third-party-libraries-fx30s/3263/1 "2018-05-08T18:07:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![plu](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@plu](https://forum.legato.io/u/plu)\
**Post date:** [June 11, 2018, 3:28pm UTC](https://forum.legato.io/t/legato-and-third-party-libraries-fx30s/3263/2 "2018-06-11T15:28:22Z")

</div>

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

> [@MQTT with Legato 16.10.1 SW FX30S](https://forum.legato.io/t/mqtt-with-legato-16-10-1-sw-fx30s/3291/3):
>
> I was trying to use that code [GitHub - startwithsierra/utils-legato-mqtt: Legato MQTT client](https://github.com/startwithsierra/utils-legato-mqtt), but i cant use it from Developer Studio because some libraries cant be linked. The error is: “C:\Legato\workspace\pruebaLegatoMqtt/pruebaLegatoMqttComponent/src/json/swir\_json.c:17:32: fatal error: src/json/swir\_json.h: No such file or directory” The code that you send is like compile a full firmware an install it on the equipment, is that right?

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

onto [Legato.io](http://Legato.io) there is a page on how to add a third-party library  
[Add 3rd Party Files - Legato Docs](https://docs.legato.io/latest/howToAdd3rdParty.html)

Regards
