2

I'm attempting to compile a client program of gpsd using the following command:

g++ gpsClient.cpp -o gpsClient $(pkg-config --cflags --libs libgps)

The source code begins like that

#include <libgpsmm>

The error is the following:

Package libgpsmm was not found in the pkg-config search path.
galaxy
  • 159
  • 1
  • 7
  • Do you have other packages named `*gps*` in `/usr/lib/pkgconfig`? Try them instead of `libgpsmm`. Failing that, try to install one or more packages named `libgps*` or `gpsd*` and repeat. – n. m. could be an AI Sep 09 '14 at 16:53
  • I don't have any packages named *gps* in /usr/lib/pkgconfig. I've installed the gpsd deamon with the following command: sudo apt-get install gpsd gpsd-clients – galaxy Sep 09 '14 at 16:57
  • @vudu Don't check for `gps`, check for `*gps*`. You can also run `pkg-config --list-all` to get a list of all libraries. You can search for `*gps*` by piping the output to `grep`: `pkg-config --list-all | grep -i *gps*` – Some programmer dude Sep 09 '14 at 17:51
  • @JoachimPileborg I run `pkg-config --list-all` and I´ve found a `libgps` package, then now it works. Also, the calling is `#include ` not `#include `. – galaxy Sep 09 '14 at 18:06

2 Answers2

3

Answering in case someone else encounters this issue.

The proper header file to include is, as suggested in the comments:

#include <libgpsmm.h>

pkg-config should then be able to find the proper search path, assuming gpsd (and/or depending on the OS, libgps-dev or variants thereof) is installed.

There's a good gist on github I use as a base for interacting with gpsd clients in C++ here: example c++ gpsd program using libgpsmm

It even has an example compile command (adapt to clang or other if needed):

g++ -Wall -std=c++17 -pedantic $(pkg-config --cflags --libs libgps) gpsd-example.cpp -o gpsd-example
Simog
  • 193
  • 3
  • 13
1

To get data from gpsd, make sure you have installed libgps-dev:

sudo apt install libgps-dev

And in case you want to use it in CMakeLists, gps- and m-linker flags should be linked to the target:

set(GPS_FLAGS m gps)
#
# other components  
# 
add_executable([PROJECT_NAME] ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries([PROJECT_NAME] ${GPS_FLAGS})
Keivan
  • 1,300
  • 1
  • 16
  • 29