# Cross build libmosquitto static library for Android

**URL:** <https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560>\
**Category:** Integrations\
**Created:** [May 28, 2022, 10:44am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560 "2022-05-28T10:44:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [May 28, 2022, 10:44am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/1 "2022-05-28T10:44:55Z")

</div>

Hi

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?

Can anyone help me here?

Chris

---

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [May 29, 2022, 10:13am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/2 "2022-05-29T10:13:32Z")

</div>

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

Chris

---

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [May 29, 2022, 11:33am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/3 "2022-05-29T11:33:25Z")

</div>

spoke too soon - it just builds for linux still! doh!

will keep trying…

---

<div class="post-metadata">

**Author:** ![roger.light](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@roger.light](https://forum.cedalo.com/u/roger.light)\
**Post date:** [May 31, 2022, 12:01pm UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/4 "2022-05-31T12:01:23Z")

</div>

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.

Cheers,

Roger

---

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [June 12, 2022, 7:57am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/5 "2022-06-12T07:57:02Z")

</div>

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;

make[2]: \*\*\* [plugins/message-timestamp/CMakeFiles/mosquitto\_message\_timestamp.dir/build.make:103: plugins/message-timestamp/mosquitto\_message\_timestamp.so] Error 1

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;

> <https://github.com/eclipse/mosquitto/commit/b6b803991449d213b0314676c47d9d0f91b8306d>
>
> This was due to the openssl ctx not being initialised until starting to connect.…
> 
> Closes #2537. Thanks to chessing-c4.

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.

Any ideas?

---

<div class="post-metadata">

**Author:** ![emmaagro](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/emmaagro/32/546_2.png) [@emmaagro](https://forum.cedalo.com/u/emmaagro)\
**Post date:** [April 13, 2024, 7:54am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/6 "2024-04-13T07:54:52Z")

</div>

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](https://core-ball.org/) 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.

---

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [April 13, 2024, 8:17am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/7 "2024-04-13T08:17:26Z")

</div>

Hi emmaagro,

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](https://github.com/TheBlackSheep/godot-mqtt) (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?

Chris

---

<div class="post-metadata">

**Author:** ![Larisabrownb](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/larisabrownb/32/572_2.png) [@Larisabrownb](https://forum.cedalo.com/u/Larisabrownb)\
**Post date:** [September 9, 2024, 5:04am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/8 "2024-09-09T05:04:46Z")

</div>

I’m trying to cross -build the mosquitto library for Android - I am building (as part of a Godot game engine [love language test](https://lovelanguagetest.org/) 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.

---

<div class="post-metadata">

**Author:** ![TheBlackSheep](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@TheBlackSheep](https://forum.cedalo.com/u/TheBlackSheep)\
**Post date:** [September 9, 2024, 7:22am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/9 "2024-09-09T07:22:49Z")

</div>

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.

Chris

---

<div class="post-metadata">

**Author:** ![miaalexandra](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/miaalexandra/32/598_2.png) [@miaalexandra](https://forum.cedalo.com/u/miaalexandra)\
**Post date:** [February 11, 2025, 5:05am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/10 "2025-02-11T05:05:02Z")

</div>

I’m trying to cross-build the mos quitto library for Android\* - I am building (as part of a Godot game engine installation) support for MQTT client. If you have ccmake installed, you simply need to [Spacebar clicker](https://spacebar-clicker.org/) set WITH\_STATIC LIBRARIES\* to ON and compile. Libraries will be located in build lib want to generate arm32 and 64-bit static libraries for the _android_ platform, then i create a shell in root dir. Then everything looks fine …

---

<div class="post-metadata">

**Author:** ![lew-wa](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@lew-wa](https://forum.cedalo.com/u/lew-wa)\
**Post date:** [February 14, 2025, 7:44pm UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/11 "2025-02-14T19:44:46Z")

</div>

Am I correct in the assumption that you did your cross-compile from the command line or did you use an IDE? I’m looking at the possibility of having to do the same operation.

---

<div class="post-metadata">

**Author:** ![charlotteemma](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/charlotteemma/32/577_2.png) [@charlotteemma](https://forum.cedalo.com/u/charlotteemma)\
**Post date:** [July 18, 2025, 7:09am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/12 "2025-07-18T07:09:49Z")

</div>

Hi. I’m trying to cross-build the mosquitto library for Android - I am building (as part of a Godot game engine installation) support for … If you have ccmake installed, you simply need to [spacebar counter](https://spacebarcounter.org/) set WITH\_STATIC\_LIBRARIES to ON and compile. Libraries will be located in build lib.

---

<div class="post-metadata">

**Author:** ![norajohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/norajohnson/32/615_2.png) [@norajohnson](https://forum.cedalo.com/u/norajohnson)\
**Post date:** [July 25, 2025, 6:15am UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/13 "2025-07-25T06:15:30Z")

</div>

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. I’m trying to export my JUCE app to Android , but am [monkey type](https://monkey-type.net/) struggling with attaching pre-compiled shared _libraries_ with ProJucer, three of them: mosquitto, openssl …

---

<div class="post-metadata">

**Author:** ![olivaava](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.cedalo.com/olivaava/32/628_2.png) [@olivaava](https://forum.cedalo.com/u/olivaava)\
**Post date:** [September 23, 2025, 2:13pm UTC](https://forum.cedalo.com/t/cross-build-libmosquitto-static-library-for-android/560/14 "2025-09-23T14:13:47Z")

</div>

Threaded build of mosquitto library for Windows? Mosquitto MQTT … Cross build libmosquitto static library for Android The [live car game](https://livecargame.netlify.app/) Android databinding library is a support library that lets you use a declarative style instead of programming to connect UI components in your layouts to data sources in your apps. Layouts are frequently defined in activities by using UI framework functions with code
