Interface to the Eclipse Paho MQTT client library for Fortran 2008
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A Fortran 2008 interface to the Eclipse Paho MQTT client library. Currently, f08paho is just a proof of concept.


In order to use the interface, you will need a Fortran 2008 compiler for building and the Eclipse Paho C library for linking. Compilation has been tested with GNU Fortran 8, but should work with other modern compilers as well.

Build Eclipse Paho

If Eclipse Paho is not already installed, clone the GitHub repository and build it from source:

$ git clone
$ cd paho.mqtt.c/
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install

If you do not want to install Eclipse Paho globally with make install, copy paho.mqtt.c to you working directory. You then have to alter the f08paho Makefile and change the CFLAGS parameter to:

CFLAGS = -Wall -std=2008 \
         -Wl,-rpath=/usr/local/lib/gcc8/ \
         -Wl,-rpath=./paho.mqtt.c/build/src/ \
         -I./paho.mqtt.c/src/ -L./paho.mqtt.c/build/src/

The GCC runtime path -Wl,-rpath=/usr/local/lib/gcc8/ is required only on FreeBSD.

Build the Fortran interface

Clone the repository with Git and use GNU make to build the Fortran interface:

$ git clone
$ cd f08paho/
$ make paho

You can override the default compiler (gfortran8) by passing the FC argument, for example:

$ make paho FC=gfortran

Or compile the interface manually:

$ gfortran8 -c paho.f90

Add -lpaho-mqtt3c to your LDFLAGS to link Eclipse Paho, for instance:

$ gfortran8 -Wl,-rpath=/usr/local/lib/gcc8/ -I/usr/local/include/ -L/usr/local/lib/ \
  -o example example.f90 paho.o -lpaho-mqtt3c


The source code of some demo applications is located in directory examples/. The examples require a running MQTT message broker. Either start a local broker or connect to on port 1883.

  • subscribe connects to an MQTT message broker, subscribes a topic, and prints the payload of received messages.
  • publish connects to an MQTT message broker and publishes to a topic.
  • plot uses json-fortran and DISLIN to plot data in real-time.

Build the examples with:

$ make <name>