Arduino Create Web Editor: undefined reference to `MQTTAsync_connect'


I’m trying to develop a C program that publishes temperature & humidity sensor data via MQTT on an Intel Up2 board. I’m using Arduino Create Web Editor to develop my program. The code is from an example project and everything was working fine in the past few weeks.

Here is the code:

// Eclipse Paho MQTT - Version: Latest 
#include <ArduinoPahoASync.h>
#include <MQTTAsync.h>
#include <MQTTClient.h>
#include <MQTTClientPersistence.h>

// JSON-C - Version: Latest 
#include <ArduinoJsonC.h>
#include <json-c/json.h>

#include "th02.hpp"
#include "upm_utilities.h"

#define ADDRESS     "tcp://localhost:1883"
#define CLIENTID    "MQTTExample"
#define TOPIC_ONE   "sensors/temperature/data"
#define TOPIC_TWO   "sensors/humidity/data"
#define QOS         1
#define TIMEOUT     10000L

int finished = 0;
void connLost(void *context, char *cause);
void onConnectFailure(void* context, MQTTAsync_failureData* response);
void onConnect(void* context, MQTTAsync_successData* response);
void onSend(void* context, MQTTAsync_successData* response);
int main();
void connLost(void *context, char *cause) {
  MQTTAsync client = (MQTTAsync)context;
  MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
  int rc;

  printf("\nConnection lost\n");
  printf("     cause: %s\n", cause);

  conn_opts.keepAliveInterval = 20;
  conn_opts.cleansession = 1;
  if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS) {
    printf("Failed to start connect, return code %d\n", rc);
    finished = 1;
void onConnectFailure(void* context, MQTTAsync_failureData* response) {
  printf("Connect failed, rc %d\n", response ? response->code : 0);
  finished = 1;
void onConnect(void* context, MQTTAsync_successData* response) {
  printf("Successful connection\n");

void onSend(void* context, MQTTAsync_successData* response) {

  printf("Message with token value %d delivery confirmed\n", response->token);
  finished = 1;
main() {
  // Set the subplatform for the shield
  mraa_add_subplatform(MRAA_GROVEPI, "0");

  // Create the temperature & humidity sensor object 
  upm::TH02 sensor;

  MQTTAsync client;
  MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
  int rc;


  MQTTAsync_setCallbacks(client, NULL, connLost, NULL, NULL);

  conn_opts.keepAliveInterval = 20;
  conn_opts.cleansession = 1;
  conn_opts.onSuccess = onConnect;
  conn_opts.onFailure = onConnectFailure;
  conn_opts.context = client;
  if ((rc = MQTTAsync_connect(client, &conn_opts)) !=  MQTTASYNC_SUCCESS) {
    printf("Failed to start connect, return code %d\n", rc);
  // Read the temperature and humidity printing both the Celsius and
  // equivalent Fahrenheit temperature and Relative Humidity, waiting two seconds between readings
  while (1) {
      float celsius = sensor.getTemperature();
      float fahrenheit = (celsius * 9.0 / 5.0 + 32.0);
      float humidity = sensor.getHumidity();
      printf("%2.3f Celsius, or %2.3f Fahrenheit\n", celsius, fahrenheit);
      printf("%2.3f%% Relative Humidity\n", humidity);
      // Create JSON Objects for MQTT
      char cnum[13];
    sprintf(cnum, "%3.7f", celsius);
    char hnum[13];
    sprintf(hnum, "%3.7f", humidity);
    struct timeval time;
    char snum[13];
    sprintf(snum, "%d", (int) time.tv_sec);
    char *sensor = "sensor_id";
    char *temper = "temperature";
    char *humid = "humidity";
    char *value  = "value";
    char *timet   = "timestamp";
    //Create the json object for TOPIC_ONE i.e temperature
    struct json_object *jobj_1;
    jobj_1 = json_object_new_object();
    json_object_object_add(jobj_1, sensor, json_object_new_string(temper));
    json_object_object_add(jobj_1, value, json_object_new_string(cnum));
    json_object_object_add(jobj_1, timet, json_object_new_string(snum));
    //Create the json object for TOPIC_TWO i.e humidity
    struct json_object *jobj_2;
    jobj_2 = json_object_new_object();
    json_object_object_add(jobj_2, sensor, json_object_new_string(humid));
    json_object_object_add(jobj_2, value, json_object_new_string(hnum));
    json_object_object_add(jobj_2, timet, json_object_new_string(snum));
    char *str_mqtt;

    str_mqtt = (char *) json_object_to_json_string(jobj_1);
    MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
      MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
      opts.onSuccess = onSend;
      opts.context = client;
    // Send JSON Object via MQTT
      pubmsg.payload = str_mqtt;
      pubmsg.payloadlen = strlen(str_mqtt);
      pubmsg.qos = QOS;
      pubmsg.retained = 0;

      // Publish TOPIC_ONE
      if ((rc = MQTTAsync_sendMessage(client, TOPIC_ONE, &pubmsg, &opts)) != MQTTASYNC_SUCCESS) {
        printf("Failed to start sendMessage, return code %d\n", rc);
      // Wait until message is sent
      while (!finished) {
      str_mqtt = (char *) json_object_to_json_string(jobj_2);
    // Send JSON Object via MQTT
      pubmsg.payload = str_mqtt;
      // Publish TOPIC_ONE
      if ((rc = MQTTAsync_sendMessage(client, TOPIC_TWO, &pubmsg, &opts)) != MQTTASYNC_SUCCESS) {
        printf("Failed to start sendMessage, return code %d\n", rc);
      // Wait until message is sent
      while (!finished) {

  return 0;

Without any change in the settings and the code, today when I tried to re-verify (or re-compile) the code, I got the following error messages (for complete error message please see the attachment below):

./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -build-path /tmp/065750912/build -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -libraries /tmp/065750912/pinned -libraries /tmp/065750912/custom -fqbn arduino:mraa:intel_x86_64 -build-cache /tmp -logger humantags -verbose=false /tmp/065750912/sketch_temperature_humidity_MQTT

/tmp/065750912/build/sketch/sketch_temperature_humidity_MQTT.ino.cpp.o: In function `connLost(void*, char*)':

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:35: undefined reference to `MQTTAsync_connect'

/tmp/065750912/build/sketch/sketch_temperature_humidity_MQTT.ino.cpp.o: In function `main':

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:89: undefined reference to `MQTTAsync_create'

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:91: undefined reference to `MQTTAsync_setCallbacks'

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:98: undefined reference to `MQTTAsync_connect'

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:180: undefined reference to `MQTTAsync_sendMessage'

/tmp/065750912/sketch_temperature_humidity_MQTT/sketch_temperature_humidity_MQTT.ino:200: undefined reference to `MQTTAsync_sendMessage'

collect2: error: ld returned 1 exit status

exit status 1

I have confirmed that the “Eclipse Paho MQTT” library is included (it came with the board as part of the pre-installed packages), and Arduino Create Web Editor doesn’t allow me to delete and re-install the library. Does anyone know why this is happening and how to fix it? If I want to manually compile the code without using Arduino Create Web Editor, how can I achieve that? I’ve downloaded Arduino IDE but found it doesn’t support Intel UP2 board.

Thanks for your help.

Complete_error_message.txt (33.8 KB)

I'm using Arduino Create Web Editor to develop my program.

There is a section of the forum for the web editor. This is NOT it.

If you have the same issue with the desktop IDE, then you can ask here.

Just found the "Web Editor" section ... sorry.