[fpc-pascal] libmosquitto headers for FPC

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Thu Mar 14 15:46:42 CET 2019


Not sure if anyone have done this already, but I converted the
libmosquitto (which is a C-written MQTT client library) header
(mosquitto.h) to Free Pascal, so it allows using libmosquitto from Pascal
code. I work on some IoT projects lately which transfers data over MQTT,
and I wanted to write some of the code in Pascal (after some other
languages failed to meet expectations, business as usual), so I just did
it. I know some Pascal MQTT libraries exist, but all I encountered seemed
to have some limitations, or things I didn't like (being too Delphi
centric, or something) and libmosquitto just seems to be much more used.

Note this is only a pure conversion of the C header file using ctypes,
with some pascalisms added (like proper callback function types). I have
an additional class-layer on top of it planned, but so far I only got the
headers converted, but they work in our internal project. I want to add
some examples later too.

So in case anyone needs this:


As we hopefully will soon use this in production, I sort of committed
to keep the headers up-to-date.

I tested it on Darwin (x86_64) and Linux (x86_64 and arm), but adding
Windows support should be trivial. (Probably only needs the right .dll
name added as linklib, or something.)


More information about the fpc-pascal mailing list