kevinmehall / rust-soapysdr

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

macOS llvm and libc errors #19

Closed JuliDi closed 1 year ago

JuliDi commented 3 years ago

Hi,

apparently there are linker errors when trying to compile this on macOS. However, there seems to be a solution that I would like to share here – in case anyone else is trying the same thing:

  1. Install llvm with homebrew: $ brew install llvm
  2. Make sure the commandline tools are installed and check whether libclang is available at /Library/Developer/CommandLineTools/usr/lib/libclang.dylib. Running cargo build now unfortunately gives the following error:
    
    error: failed to run custom build command for `soapysdr-sys v0.7.2 (/Users/<user>/rust-soapysdr/soapysdr-sys)`

Caused by: process didn't exit successfully: /Users/<user>/rust-soapysdr/target/debug/build/soapysdr-sys-a03975fe81e5e189/build-script-build (signal: 6, SIGABRT: process abort signal) --- stderr dyld: Library not loaded: @rpath/libclang.dylib Referenced from: /Users//rust-soapysdr/target/debug/build/soapysdr-sys-a03975fe81e5e189/build-script-build Reason: image not found


3. Build the project using `$ export DYLD_LIBRARY_PATH=/Library/Developer/CommandLineTools/usr/lib/ cargo build`

For some reason, the `clang` library can't be found automatically and we have to help the linker (see https://github.com/rust-qt/ritual/issues/75)

Hope this helps.

@kevinmehall thanks for making this project available!
inganault commented 2 years ago

This probably related to rust-bindgen 0.52 features changes. PR #20 should already fixed it, but I don't have macOS to verify.

tommy-gilligan commented 1 year ago

Looks like this has been fixed

tom@mini rust-soapysdr %  brew install llvm
Warning: llvm 16.0.6 is already installed and up-to-date.
To reinstall 16.0.6, run:
  brew reinstall llvm
tom@mini rust-soapysdr % ls /Library/Developer/CommandLineTools/usr/lib/libclang.dylib
/Library/Developer/CommandLineTools/usr/lib/libclang.dylib
tom@mini rust-soapysdr % cargo clean
tom@mini rust-soapysdr % cargo build
   Compiling memchr v2.5.0
   ...
   Compiling cexpr v0.6.0
   Compiling soapysdr-sys v0.7.4 (/Users/tom/rust-soapysdr/soapysdr-sys)
   Compiling soapysdr v0.3.2 (/Users/tom/rust-soapysdr)
    Finished dev [unoptimized + debuginfo] target(s) in 6.21s
tom@mini rust-soapysdr % export DYLD_LIBRARY_PATH=/Library/Developer/CommandLineTools/usr/lib/ cargo build
tom@mini rust-soapysdr % echo $?
0
tom@mini rust-soapysdr % cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
tom@mini rust-soapysdr % uname -a
Darwin mini 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112 arm64

Xcode Version 14.3.1 (14E300c)