kevinmehall / rust-soapysdr

Rust bindings for SoapySDR, the vendor-neutral software defined radio hardware abstraction layer
Apache License 2.0
79 stars 22 forks source link

MacOS fails to find SoapySDR #31

Closed thisjaiden closed 1 year ago

thisjaiden commented 1 year ago

After the recent upgrade, soapysdr-sys 0.7.5 fails to complete building, citing not finding SoapySDR in the pkg-config search path. My environment:

Setting PKG_CONFIG_PATH equal to the install location under homebrew does not resolve the issue.

The full error message is below:

error: failed to run custom build command for `soapysdr-sys v0.7.5`

Caused by:
  process didn't exit successfully: `/Users/thisjaiden/Desktop/rustio/target/debug/build/soapysdr-sys-51a83ef83d09ee0e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=SOAPYSDR_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=SOAPYSDR_STATIC
  cargo:rerun-if-env-changed=SOAPYSDR_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  pkg_config: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" PKG_CONFIG_PATH="/opt/homebrew/Cellar/soapysdr/0.8.1_1/lib" "pkg-config" "--libs" "--cflags" "SoapySDR" "SoapySDR >= 0.6.0"` did not exit successfully: exit status: 1
  error: could not find system library 'SoapySDR' required by the 'soapysdr-sys' crate

  --- stderr
  Package SoapySDR was not found in the pkg-config search path.
  Perhaps you should add the directory containing `SoapySDR.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'SoapySDR' found
  Package SoapySDR was not found in the pkg-config search path.
  Perhaps you should add the directory containing `SoapySDR.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'SoapySDR' found

  thread 'main' panicked at 'Couldn't find SoapySDR',

I've tried a cargo clean, manually cleaning out cargo stuff, and reinstalling SoapySDR.

Let me know if there's anything else I can provide or do to help.

kevinmehall commented 1 year ago

Hmm, this doesn't look related to the build.rs changes in the latest 0.7.5 release of soapysdr-sys -- it added an environment variable that is checked first, but your log is clearly running pkg-config so that option is not being taken.

@tomgilligan any other advice on using this on MacOS?

tommy-gilligan commented 1 year ago

Out at the moment. Will respond properly about 7 hours from now but I can advise on this.

thisjaiden commented 1 year ago

Thanks for the quick response and advice, here's the update:

Thank you again!

tommy-gilligan commented 1 year ago

@thisjaiden I'm glad this has worked out for you!

Here's some information from my system that might help you get to the bottom of what is going on with pkg-config. PKG_CONFIG_PATH is unset for me. Running pkg-config scans /opt/homebrew/lib/pkgconfig (so I guess you could try setting PKG_CONFIG_PATH to /opt/homebrew/lib/pkgconfig)

tom@mini ~ % printenv PKG_CONFIG_PATH
tom@mini ~ % find /opt -iname 'soapy*.pc' -ls
57084163        0 lrwxr-xr-x    1 tom              admin                  55  6 Jul 11:57 /opt/homebrew/lib/pkgconfig/SoapySDR.pc -> ../../Cellar/soapysdr/0.8.1_1/lib/pkgconfig/SoapySDR.pc
57084154        8 -r--r--r--    1 tom              admin                 373  6 Jul 11:57 /opt/homebrew/Cellar/soapysdr/0.8.1_1/lib/pkgconfig/SoapySDR.pc
tom@mini ~ % which pkg-config
/opt/homebrew/bin/pkg-config
tom@mini ~ % pkg-config --debug --list-all 2>&1 | head
Error printing disabled by default due to use of output options --exists, --atleast/exact/max-version, --list-all or no output option at all. Value of --print-errors: 0
Error printing disabled
Scanning directory '/opt/homebrew/lib/pkgconfig'
...
thisjaiden commented 1 year ago

It looks like the issue was I made some changes to $PATH and caused the pkg-config installed by MacPorts, which does not know about my homebrew packages, to take priority. I was able to track down some people who made the same mistake here.

Final thank you for the great and quick responses! It's much appreciated :)