I’m trying to cross-build the mosquitto library for Android - I am building (as part of a Godot game engine installation) support for MQTT client. The static library builds fine under Linux (Ubuntu) with openssl 1.1.1 but as part of the cross-compilation process within Godot is the rebuild of Android templates to include user included libraries - in this case libmosquitto. There is a comment in the changelog saying there were changes a long time ago so it will build for Android but I can’t find anywhere how to do this?
I’ll answer my own question so it helps anyone else - I downloaded the openssl library for the same basis and in the NOTES.ANDROID file there is the necessary setup which is quite simple;
export ANDROID_NDK_HOME=/home/chris/Android/Sdk/ndk/21.4.7075529
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
./Configure android-arm64 -D__ANDROID_API__=22
make clean
make
I save that as a re-usable script and used it for building openssl and mosquitto, Other than the paths for a different version of the NDK the only thing I added was “make clean” which I found was necessary if you’d already built a previous version for a different platform
I’m afraid I can’t help much - the contribution which fixed building on Android was in the code, not in the build part. I don’t know how the person doing it was actually doing the build.
OK got it building now for all Android platforms and Ubuntu 21.10 (both from latest sources and supposedly the same version that’s currently in 21.10 (version 2.0.11) - however neither works with openSSL (which I’m also building from similar dated versions 1.1.1o and 1.1.1k from last year). The only error I see when building is one of the plugin examples;
It builds fine on Linux but fails on Android (all versions).
However, when connecting to HiveMQ which requires a TLS connection it always throws a “Error: A TLS error occurred.” - I have also tried the change from;
in both versions of openssl (1.1.1o and 1.1.1k) and mosquitto (latest and 2.011)
but that hasn’t changed anything - when running the newly built command line tools (mosquitto_pub and mosquitto_sub) I still get the TLS error despite giving the --insecure and/or —tls-use-os-certs.
I’m trying to cross build the mosquitto library for Android - I am building (as part of a Godot game engine installation) support for MQTT …to establish a persistent, bidirectional communication channel between the web client and the server. This allows for real-time syncing core ball of messages and other data between the mobile device and the web client. The Secure MQTT Broker is written in C & Python and works with all standard MQTT Clients. Bevywise MQTT Broker has a FREE and affordable premium version. MQTTRoute can be customized to write data to any data store using standard connectors or custom implementations.
I gave up on this approach as it just became too complicated, interestingly mine was for Godot too but it needed to be moved to GDExtension and I gave up (couldn’t get cross-build from Linux to Windows and never tried a Mac cross-build). However, I have a repo on Github GitHub - TheBlackSheep/godot-mqtt: Godot addon which implements the MQTT client protocol (I can’t take the credit for it - it’s a fork of someone elses attempts to get a gdscript version working, my changes were just minor tweaks to get it working with (secure) HiveMQ as well as an unsecure locally running Mosquitto - the author uses it on Android for a VR project and I’ve tested it for basic functionality (publishing and subscribing) on Windows, Linux and MacOS. Maybe you could try this?
I’m trying to cross -build the mosquitto library for Android - I am building (as part of a Godot game engine love language test installation) support for MQTT … Dynamic linking keeps these libraries as separate files.Static linking results in larger executable files which contain more code. This additional code coming from libraries cannot be shared across multiple programs on the system, increasing file system usage and memory usage at run time.
Hi Larisa, I can certainly send you the shell scripts I had written (or I could just put them on Github) - my approach was to build openssl first (for each platform) and then link each cross-built mosquitto library to the relevant openssl version and finally build Godot using the two libraries (per platform). I sort of got Android and Linux built - as far as I remember Linux compiled ok and ran but the Android always just froze. I was never successful at cross-building the Windows version either and I never got to the point I could try a MacOS cross-build.