Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When building against airspyhf, link against libm #35

Merged
merged 1 commit into from Jul 28, 2022

Conversation

paultag
Copy link

@paultag paultag commented Jun 15, 2022

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.

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.
@touil touil merged commit 20119f4 into airspy:master Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants