Basically, I have the paho-mqtt-c library installed in my rootfs using Yocto build environment. Since it was already included in meta-oe layer, I simply had to add that recipe to IMAGE_INSTALL_append variable.
I confirmed this by checking the following:
root@am65xx-evm:/usr/lib# ls | grep mqtt
libpaho-mqtt3a.so.1
libpaho-mqtt3a.so.1.0
libpaho-mqtt3as.so.1
libpaho-mqtt3as.so.1.0
libpaho-mqtt3c.so.1
libpaho-mqtt3c.so.1.0
libpaho-mqtt3cs.so.1
libpaho-mqtt3cs.so.1.0
Being a novice with building cross-compiled applications and setting up tool chains, I have a basic question which I couldn't exactly find an answer for.
Now that my target machine has the library installed, how to I develop an application on my host machine running Ubuntu 18.04 LTS?
I can do apt-get install and get the same library, but using the cross compiler to compile the C file, it is not able to see the the MQTT Library.
For example:
~/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc mqtt-test.c -l paho-mqtt3c
mqtt-test.c:4:10: fatal error: MQTTClient.h: No such file or directory
#include "MQTTClient.h"
^~~~~~~~~~~~~~
compilation terminated.
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "file://mqtt-test.c \
file://COPYING"
S = "${WORKDIR}"
TARGET_CC_ARCH += "${LDFLAGS}"
DEPENDS = "paho-mqtt-c"
do_compile() {
${CC} mqtt-test.c -o mqtt-test ${CFLAGS} -lpaho-mqtt3c
}
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/mqtt-test ${D}${bindir}
}
This is the recipe I used with the following directory structure:
Ignore the lmbench and hello-world - they were a sample from TI's tutorial.
Notice the DEPENDS = "paho-mqtt-c"
Apparently the -lpaho-mqtt3c
flag with the do_compile()
seemed to work this time.
I still wonder why I could't simply invoke the Linaro compiler and compile this separately.