Skip to content

[GPS] How to build/add gps library on CMakeLists.txt and use it for x86 client | gpsd

GPS Penguin, Earth Satellite
GPS Penguin, Earth Satellite

In fact, I think the beginning of interest is how to include <gps.h> in my code and make the build successful.

In this posting, it is not guaranteed by the operation of gps, but how the build will succeed, and how to use the API.

How to build it

1️⃣ If gpsd-clients and gpsd are installed by apt, remove them. Because these packages do not contain the header files and libraries required for my client build. So you have to download the source code and install it after building it.

sudo apt purge gpsd-clients
sudo apt purge gpsd

In fact, the essential packages needed for the build are introduced at However, my Linux machine already had packages installed for other builds, so there was no dependency issue without installing any packages. These are essential packages based on Ubuntu 18.04 LTS.

apt install gcc scons python-gi python-gi-cairo g++
apt install libncurses5-dev libtinfo-dev  pps-tools
apt install gir1.2-gtk-3.0

2️⃣ Take the source code as wget. The site is below. I received gpsd-3.24.tar.gz.

tar -xvf gpsd-3.24.tar.gz
cd gpsd-3.24

3️⃣ And to build the source code, sudo permission is required for installation.

scons && scons check 
sudo scons udev-install

If you have done so far, the gpsd is installed, but it is not working. However, adding a library to my gps client and building is possible. The content that makes it work with fake data will be found out later.

$ systemctl status gpsd
● gpsd.service - GPS (Global Positioning System) Daemon
     Loaded: loaded (/lib/systemd/system/gpsd.service; disabled; vendor preset: enabled)
     Active: inactive (dead)

4️⃣ Add gps to CMakeLists.txt and <gps.h> to code that uses the gps API to enjoy coding. Can you build it?

target_link_libraries(<module name>

How to use it

For coding, how to use gpsd is introduced at In summary, there are three uses. Socket interface, shared-memory interface, and D-Bus broadcast.

The easiest way is to use the shared-memory interface However, it seems that GET works, but SET doesn’t work.

Socket interface and D-Bus interface can be applied and my code requires threads or proxies for message handling, but I don’t think it’s a simple implementation. We will find out about this part when the approach of my implementation is determined.

I think the GPS data format is JSON. It also kindly provides the JSON Parser API (gps_unpack()). - Table 1. Entry points in client bindings – Table 1. Entry points in client bindings


  • Building GPSD from source
  • GPSD Client HOWTO

Leave a Reply

Your email address will not be published. Required fields are marked *