Skip to content

Instantly share code, notes, and snippets.

@igricart
Last active November 17, 2020 14:07
Show Gist options
  • Save igricart/8feeef1865079c7ff9dfb7d0f06a444a to your computer and use it in GitHub Desktop.
Save igricart/8feeef1865079c7ff9dfb7d0f06a444a to your computer and use it in GitHub Desktop.
Install-Create Deb package Paho MQTT C/Cpp

How create a debian package out of Paho MQTT C

$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c

# Check version from Paho MQTT Cpp too
$ git checkout v1.3.1

Then run

# To install in /usr/local
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF
$ sudo cmake --build build/ --target install

# To install in a custom path (paho.mqtt.c/install)
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=install
$ cmake --build build/ --target install

# To create a package
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_DEB_PACKAGE=ON
$ sudo cmake --build build/ --target package

Update link path

$ sudo ldconfig

How create a debian package out of Paho MQTT Cpp

Run

$ git clone https://github.com/eclipse/paho.mqtt.cpp
$ cd paho.mqtt.cpp

Generating debian

$ cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_BUILD_DEB_PACKAGE=TRUE
$ cd build
$ dh_make -p paho-mqtt-cpp_0.1.1 --createorig -s -y

Copy the following file to debian/rules

%:
       dh $@
override_dh_usrlocal:
       dh $@

override_dh_shlibdeps:
       dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

Bear in mind that there are TABS instead of spaces

Then run

$ dpkg-buildpackage -b -uc

Other builds

Depending on the build, one could have the following rules

# Install in /usr/local/
$ cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE
$ sudo cmake --build build/ --target install
$ sudo ldconfig

# to generate tar.gz 
$ cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_BUILD_DEB_PACKAGE=TRUE
$ sudo cmake --build build/ --target package
$ sudo ldconfig

[DEPRECATED] Convert tar.gz pkg to .deb

$ sudo apt install checkinstall
$ cd build
$ sudo checkinstall -t debian -y --pkgname=libpaho-mqtt-cpp --pkgversion=1.3.6

Check install may not bring all files Alien could be one option, but may have some issues according to the previous link

$ sudo apt-get install alien
$ sudo alien -d tarball.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment