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

Doesn't compile on macOS #1

Closed
Peacekeeper2000 opened this issue Aug 11, 2017 · 5 comments
Closed

Doesn't compile on macOS #1

Peacekeeper2000 opened this issue Aug 11, 2017 · 5 comments

Comments

@Peacekeeper2000
Copy link

I do have the problem that it doesn't compile on macOS. I am sure I make something wrong, but I have no clue what its .... Maybe you could help ...

cargo build --release
warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#hid:0.4.0
Compiling nitrocli v0.1.0 (file:https:///nitrocli/nitrocli)
error: linking with cc failed: exit code: 1
|
= note: “cc” “-m64” “-L” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib” “/nitrocli/nitrocli/target/release/deps/nitrocli-e29bae10c035e61e.0.o” “-o” “/nitrocli/nitrocli/target/release/deps/nitrocli-e29bae10c035e61e” “-Wl,-dead_strip” “-nodefaultlibs” “-L” “/nitrocli/nitrocli/target/release/deps” “-L” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib” “-l” “c” “/nitrocli/nitrocli/target/release/deps/libhid-488dd42f7cb67d27.rlib” “/nitrocli/nitrocli/target/release/deps/libhidapi_sys-d6356264c78813c0.rlib” “/nitrocli/nitrocli/target/release/deps/liblibc-39e9fe8562e55f31.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-438eba4cd7d88a45.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-00160610bfa2c7b4.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-88eece318c5ccb15.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-646fe8114e6965a2.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcollections-7d6da376f6405c93.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-ab03bba0be78edaa.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-3d46a711e5badb84.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-31c7158cd96c571c.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-a732f07ce6fa7392.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-ee2a935baf6741f5.rlib” “/Users/peacekeeper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-53f5ee584666574a.rlib” “-l” “hidapi” “-l” “System” “-l” “resolv” “-l” “pthread” “-l” “c” “-l” “m”
= note: ld: library not found for -lhidapi
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error(s)
error: Could not compile nitrocli.

@d-e-s-o
Copy link
Owner

d-e-s-o commented Aug 11, 2017

Thanks for trying out nitrocli. I have never attempted compilation on Mac (simply because I don't own one) so basically all bets are off. That said, I should be able to get my hands on one but that won't happen in the next two weeks or so as I am out of country.

However, the problem seems to be that the hidapi library is not found. It needs to be present on the system. I believe that the documentation is wrong in this respect and I will update it after verifying.
I the library from my Linux system and the compilation fails similarly:

$ cargo build --release
warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#hid:0.4.0
   Compiling gcc v0.3.48 (file:https:///tmp/nitrocli/gcc)
   Compiling pkg-config v0.3.9 (file:https:///tmp/nitrocli/pkg-config)
   Compiling libc v0.2.23 (file:https:///tmp/nitrocli/libc)
warning: variant `__Nonexhaustive_do_not_match_this_or_your_code_will_break` should have a camel case name such as `NonexhaustiveDoNotMatchThisOrYourCodeWillBreak`, #[warn(non_camel_case_types)] on by default
   --> /tmp/nitrocli/gcc/src/windows_registry.rs:102:5
    |
102 |     __Nonexhaustive_do_not_match_this_or_your_code_will_break,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   Compiling hidapi-sys v0.1.2 (file:https:///tmp/nitrocli/hidapi-sys)
   Compiling hid v0.4.0 (file:https:///tmp/nitrocli/hid)
   Compiling nitrocli v0.1.0 (file:https:///tmp/nitrocli/nitrocli)
error: linking with `x86_64-pc-linux-gnu-gcc` failed: exit code: 1
  |
  = note: "x86_64-pc-linux-gnu-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/nitrocli/nitrocli/target/release/deps/nitrocli-413d10a1aae0bdea.0.o" "-o" "/tmp/nitrocli/nitrocli/target/release/deps/nitrocli-413d10a1aae0bdea" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/nitrocli/nitrocli/target/release/deps" "-L" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "c" "/tmp/nitrocli/nitrocli/target/release/deps/libhid-2ed7f8bda96e80e4.rlib" "/tmp/nitrocli/nitrocli/target/release/deps/libhidapi_sys-21a2a9d680fb9e99.rlib" "/tmp/nitrocli/nitrocli/target/release/deps/liblibc-d0059a60b78fe406.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libstd-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/librand-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libcore-63283ac5.rlib" "/usr/lib64/rust-1.16.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-63283ac5.rlib" "-l" "udev" "-l" "hidapi-libusb" "-l" "util" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lhidapi-libusb
          collect2: error: ld returned 1 exit status

error: aborting due to previous error
error: Could not compile `nitrocli`.
To learn more, run the command again with --verbose.

Please try installing hidapi/libhid (I believe this or that may be what you need) or whatever the package is called on Mac and if there is a separate version for the USB backend you'll need that as well (but I would assume it's all in one package). That and gnupg should be the only dependencies (also see the respective ebuild).

@d-e-s-o
Copy link
Owner

d-e-s-o commented Aug 25, 2017

I just tried it out and libhid did not resolve the problem but hidapi did. I could compile nitrocli.

@d-e-s-o
Copy link
Owner

d-e-s-o commented Aug 26, 2017

Despite the successful compilation the program did not find the nitrokey device, though. That could have many reasons and your mileage may vary. But I won't be able to provide support for MacOS, so if you experience the same problem you'll have to debug that yourself.

@Peacekeeper2000
Copy link
Author

LOL - ok. Thanks for your support so far. I will try to convince NitroKey to provide their own and supported cli - think that would make sense for every NK user.
BTW: First time that I tried something in RUST. Language looks easy, what is feedback ? Especially for beginners: GO, RUST or Swift ? ( independent from the OS )

@d-e-s-o
Copy link
Owner

d-e-s-o commented Aug 26, 2017

I still recommend you first check yourself whether it really does not work. Your system may be different and I did not root cause the problem. For all I know it could be a missing driver of sorts that clearly you would have if you use the nitrokey there. I would also accept patches in that direction ;)

It's also my first project in Rust. The language itself is not too complicated, yep, but the learning curve is definitely much steeper than for Go (I haven't done anything in Swift so I can't really compare; though my take is that the same comment applies, by merely looking at the origins). I really buy into the memory safety and safe-concurrency bits of Rust, which is an incredible win in my opinion. The borrow checker sometimes gets in the way, though, in that I have to perform some (from my point of view purely) syntactic refactoring to make it happy; introduce a scope or assign a value to a variable first (or remove that assignment). But in my opinion that's worth it, I don't mind. The error messages are fairly clear.

Also Cargo makes composing programs pretty easy. I am pedantic when it comes to dependency management (as may be apparent by looking at the repo) but Cargo makes it reasonably likable (and easy), while providing enough flexibility.

What I truly think is amazing is the wide range of projects where Rust is in use. You see embedded devices (as in, so small it cannot run a Linux) being programmed with it while it also pops up in a lot of places in web development. Perhaps that's because of the hype but the interest and applicability seems legit. And the moment you have good composability and easy to use abstractions, why not?

Anyway, that's probably more than you wanted to know and the web has 1000+ more thorough reviews.

@d-e-s-o d-e-s-o closed this as completed Aug 26, 2017
@d-e-s-o d-e-s-o mentioned this issue Dec 31, 2018
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

No branches or pull requests

2 participants