Author Topic: Paho MQTT-C API  (Read 3372 times)

sylvanomtl

  • Guest
Paho MQTT-C API
« on: June 05, 2020, 09:53:38 pm »
HI there,
I am quite new to CodeBlock and I have refreshed myself using C/C++ language (I am more a Matlab guy).
I am interested in using the MQTT API from Paho: https://www.eclipse.org/paho/clients/c/#

I am using one of the example given in the examples of the API : https://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/subasync.html

I understand there is a .lib folder I need to integrate to my project. I added it using : Project > Build Option > Linker Settings > Add... 


Do you know how can I link to the folder containing the headers files?  "MQTTClient.h" ?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Paho MQTT-C API
« Reply #1 on: June 07, 2020, 02:11:44 pm »
 First you have to build the library, and install it.
Then you probably get something like
Code
installDir:
 |- bin
 |- lib
 |   |- somelibraryname.a
 | - include
     |- someheader.h

To use this library in your codeblocks project you do the following:
1) Setup the project build options:
1.1) Project->Build options->Select your project name on the left
1.2) Search directories-> Compiler
1.3) Add the include directory for the library
1.4) Search directories->Linker
1.5) Add the lib folder for the library
1.6) Linker settings->Add - the .lib file you can only the name, because you have added the folder to the search directories...

now you should be able to use it in your project.
If you have problems:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F