alexrsagen / rs-nfc1-sys

Low-level Rust bindings for libnfc. For high-level safe bindings, see crate nfc1.
MIT License
8 stars 5 forks source link

failed to run custom build command for `nfc1-sys v0.2.1` #4

Open christopherjude opened 2 years ago

christopherjude commented 2 years ago

Hello,

Good day to you. I've put crate nfc1 in my cargo.toml, when I cargo check , I'm facing a failed to run custom build command for 'nfc1-sys v0.2.1'. followed by: ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libnfc/libnfc.6.0.0.dylib] Error 1 make[1]: [libnfc/CMakeFiles/nfc.dir/all] Error 2 make: *** [all] Error 2 thread 'main' panicked at ' command did not execute successfully, got: exit status: 2 build script failed, must exit now'

Would you kindly be able to help, what should I do ?

I am on MacOS Monterey, v12.0.1 rustc 1.59.0

alexrsagen commented 2 years ago

Seems like your issue might be the same as in the following thread: https://users.rust-lang.org/t/link-failure-when-trying-to-use-cc-bindgen-to-link-c-code/27156/5

The problem was that my ar and runlib was the gnu versions, while the rest of the toolchain was Xcode.

The fix was to make sure that /usr/bin was first in the path.

Do you have different toolchains installed on your machine as well? If so, could you please try the above mentioned fix? 😄

christopherjude commented 2 years ago

Hi @alexrsagen,

Thank you so much for the prompt response ! (sorry for the delay, am quite new to this and been trying to understand the discussion in the post.) Running which -a on both ranlib and ar returns with a /usr/bin/ prefixed path, and I don't have binutils installed as well. As far as toolchains go, I believe gradle would count ?

alexrsagen commented 2 years ago

Hi again and sorry for the late response.

By toolchains, I was referring to compiler toolchains like Xcode ar and GNU (Homebrew/brew) ar (same applies to ranlib, etc). Did you install any compiler toolchains using Homebrew/brew? If so, this may be what is causing the issue.

If you have libnfc (and its dependencies, like libusb) installed, you may try removing the vendored feature, by including the nfc1-sys crate like this (same principle applies to the nfc1 wrapper crate):

[dependencies]
nfc1-sys = { version = "0.2", default-features = false }

Please let me know if you have conflicting toolchains and whether removing one (or both, then reinstalling only one) works. Alternatively let me know if removing the vendored feature works for you.

ForsakenHarmony commented 2 months ago

Has anyone found a solution for this?

I can use the library without default features, but that also disables driver support

I don't see any conflicting toolchains on my machine