Skip to content

Commit

Permalink
When building against airspyhf, link against libm
Browse files Browse the repository at this point in the history
Given a minimal example program such as:

  #include <airspyhf.h>
  void main(int argc, char** argv) {
      airspyhf_lib_version_t v;
      airspyhf_lib_version(&v);
  }

And when compiled with pkg-config, the following error is returned:

  $ gcc airspy.c -o airspy $(pkg-config --cflags --libs libairspyhf)
  /usr/bin/ld: .../libairspyhf.so: undefined reference to `sincos'
  /usr/bin/ld: .../libairspyhf.so: undefined reference to `powf'
  /usr/bin/ld: .../libairspyhf.so: undefined reference to `exp'
  /usr/bin/ld: .../libairspyhf.so: undefined reference to `cos'
  collect2: error: ld returned 1 exit status

This changeset adds in a link directive against libm, which provides the math
helpers in <math.h>. Granted; most user-programs already use libm, since, well,
raw IQ without math isn't very fun at all, so this is masked in the vast
majority of use-cases. However, in the spirit of ensuring that we're as
complete as we can, this change will allow pkg-config to return all libraries
required for linking against libairspyhf without requiring extra user provided
library flags.
  • Loading branch information
paultag committed Jun 15, 2022
1 parent b93dedd commit 65d946c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libairspyhf/libairspyhf.pc.in
Expand Up @@ -7,5 +7,5 @@ Name: AirSpy HF+ Library
Description: C Utility Library
Version: @VERSION@
Cflags: -I${includedir}/libairspyhf/ @AIRSPYHF_PC_CFLAGS@
Libs: -L${libdir} -lairspyhf
Libs: -L${libdir} -lairspyhf -lm
Libs.private: @AIRSPYHF_PC_LIBS@

0 comments on commit 65d946c

Please sign in to comment.