FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
1,881 views 5 comments
by anonymous
Hello,

I am trying to build my project but I got the error below, it can not find cJSON.h. How can I include it?

mips-openwrt-linux-musl-gcc db_dump.o print.o memory_mosq.o memory_public.o packet_datatypes.o packet_mosq.o persist_read.o persist_read_v234.o persist_read_v5.o property_mosq.o send_disconnect.o stubs.o time_mosq.o topic_tok.o utf8_mosq.o -o mosquitto_db_dump -L/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/usr/lib -L/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/lib -znow -zrelro

make[5]: Leaving directory '/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/build_dir/target-mips_24kc_musl/mosquitto-ssl/mosquitto-2.0.11/apps/db_dump'

make[5]: Entering directory '/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/build_dir/target-mips_24kc_musl/mosquitto-ssl/mosquitto-2.0.11/apps/mosquitto_ctrl'

mips-openwrt-linux-musl-gcc -I../mosquitto_passwd -DWITH_CJSON  -I. -I../../ -I../../include -I../../src -I../../lib -DWITH_TLS -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -fmacro-prefix-map=/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/build_dir/target-mips_24kc_musl/mosquitto-ssl/mosquitto-2.0.11=mosquitto-2.0.11 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/usr/include -I/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/include/fortify -I/home/ollivera/development/TRB2_R_GPL/rutos-ath79-trb2-gpl/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/include -DTRB2_PLATFORM -DSINGLE_ETH_PORT -DMOBILE_SUPPORT -DDUAL_SIM_SUPPORT -DGPS_SUPPORT   -DIO_SUPPORT  -DVERSION=\""2.0.11\"" -c mosquitto_ctrl.c -o mosquitto_ctrl.o

In file included from mosquitto_ctrl.c:19:

../../config.h:86:12: fatal error: cjson/cJSON.h: No such file or directory

 #  include <cjson/cJSON.h>

            ^~~~~~~~~~~~~~~

1 Answer

0 votes
by anonymous

Hello,

cJSON.h is in package/teltonika/libs/libtwCSdk/src/src/thirdParty/cJSON

Which os/version do you use ? Could you check your .config:

[fl@otsl rutos-ath79-trb2-gpl]$ grep -i mosquitto .config
# CONFIG_PACKAGE_libmosquitto-nossl is not set
CONFIG_PACKAGE_libmosquitto-ssl=y
# CONFIG_PACKAGE_libmosquittopp is not set
# CONFIG_PACKAGE_mosquitto-client-nossl is not set
# CONFIG_PACKAGE_mosquitto-client-ssl is not set
# CONFIG_PACKAGE_mosquitto-nossl is not set
CONFIG_PACKAGE_mosquitto-ssl=m
# CONFIG_MOSQUITTO_LWS is not set
CONFIG_MOSQUITTO_CTRL=y
CONFIG_MOSQUITTO_DYNAMIC_SECURITY=y
# CONFIG_MOSQUITTO_PASSWD is not set
Regards,

by anonymous

Hello,

I am using Ubuntu 18.04.5 LTS and TRB2_R_00.07.01.2. 

My .config: 

# CONFIG_PACKAGE_libmosquitto-nossl is not set

CONFIG_PACKAGE_libmosquitto-ssl=y

# CONFIG_PACKAGE_libmosquittopp is not set

# CONFIG_PACKAGE_mosquitto-client-nossl is not set

# CONFIG_PACKAGE_mosquitto-client-ssl is not set

# CONFIG_PACKAGE_mosquitto-nossl is not set

CONFIG_PACKAGE_mosquitto-ssl=m

# CONFIG_MOSQUITTO_LWS is not set

CONFIG_MOSQUITTO_CTRL=y

CONFIG_MOSQUITTO_DYNAMIC_SECURITY=y

# CONFIG_MOSQUITTO_PASSWD is not set

 I can see the cJSON.h in the location you mentioned. Not sure why it is not found. 

What I did before reading your answer was to create a cJSON folder under package/libs/ and add a cJSON Makefile that I got in 

https://github.com/openwrt/packages/blob/master/libs/cjson/Makefile. So, I ran `make menuconfig` and enabled it in `Libraries`. I was able to build as you can see below, but it is probably not the proper way as the cJSON is in the location you mentioned.

~/development/TRB2_R_GPL/rutos-ath79-trb2-gpl$ make package/mqttgcp/compile

WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist

WARNING: Makefile 'package/libs/glib2/Makefile' has a build dependency on 'libffi/host', which does not exist

WARNING: Makefile 'package/lang/python/python3/Makefile' has a build dependency on 'bzip2/host', which does not exist

WARNING: Makefile 'package/lang/python/python3/Makefile' has a build dependency on 'expat/host', which does not exist

WARNING: Makefile 'package/lang/python/python3/Makefile' has a build dependency on 'libffi/host', which does not exist

WARNING: Makefile 'package/network/utils/ulogd/Makefile' has a build dependency on 'libnetfilter-acct', which does not exist

 make[1] package/mqttgcp/compile

 make[2] -C package/libs/toolchain compile

 make[2] -C package/libs/cjson compile

 make[2] -C package/libs/libjson-c compile

 make[2] -C package/system/ca-certificates compile

 make[2] -C package/libs/nghttp2 compile

 make[2] -C package/libs/openssl compile

 make[2] -C package/network/utils/curl compile

 make[2] -C package/network/services/mosquitto compile

 make[2] -C package/network/services/mosquitto compile

 make[2] -C feeds/custom/examples/mqttgcp compile 

Regards, Flavio 

by anonymous

According to the README:

    We recommend using Ubuntu 20.04 LTS (http://www.ubuntu.com/download/desktop).
There may be subtle differences in the autoconf/automake/etc suite of tools.
by anonymous

Acording to the Teltonika SDK page:

Prerequisites

You will need:

  • A PC, laptop or virtual machine running Linux OS (We recommend using Ubuntu 18.04 LTS

So that's what I've installed. And having the same problem.

by anonymous
The SDK page seems outdated.
by anonymous

In my case it seems to have been a pile of wrong things.

I finally got it to compile by starting all over again.

Made a make distclean and deleted the whole sdk directory.

Uncompressed again the sdk onto a directory and made the "./scripts/feeds update"

Did the "make" again and everything went smooth.

Can't stand those compilation glitches. Really. They have made me went really mad in the past when compiling all my versions of openwrt.