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

Could not compile nfc1: no size_t in the root #8

Closed
riklus opened this issue Feb 16, 2023 · 9 comments
Closed

Could not compile nfc1: no size_t in the root #8

riklus opened this issue Feb 16, 2023 · 9 comments

Comments

@riklus
Copy link

riklus commented Feb 16, 2023

As the title states, I can't compile the module using:

Darwin riklus-macbookpro.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Jun 21 20:50:28 PDT 2022; root:xnu-7195.141.32~1/RELEASE_X86_64 x86_64
cargo 1.67.1 (8ecd4f20a 2023-01-10)
rustc 1.67.1 (d5a82bbd2 2023-02-07)

  1. Clone the repo
  2. Run cargo check
    Updating crates.io index
   Compiling libc v0.2.139
   Compiling memchr v2.5.0
   Compiling glob v0.3.1
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.51
   Compiling unicode-ident v1.0.6
   Compiling log v0.4.17
   Compiling quote v1.0.23
   Compiling clang-sys v1.4.0
   Compiling aho-corasick v0.7.20
   Compiling regex-syntax v0.6.28
   Compiling version_check v0.9.4
   Compiling cc v1.0.79
   Compiling nom v5.1.2
   Compiling libloading v0.7.4
   Compiling bitflags v1.3.2
   Compiling pkg-config v0.3.26
   Compiling regex v1.7.1
   Compiling atty v0.2.14
   Compiling rustc-hash v1.1.0
   Compiling unicode-width v0.1.10
   Compiling lazy_static v1.4.0
   Compiling peeking_take_while v0.1.2
   Compiling shlex v1.1.0
   Compiling lazycell v1.3.0
   Compiling textwrap v0.11.0
   Compiling termcolor v1.2.0
   Compiling humantime v2.1.0
   Compiling vec_map v0.8.2
   Compiling bindgen v0.58.1
   Compiling ansi_term v0.12.1
   Compiling strsim v0.8.0
   Compiling cexpr v0.4.0
   Compiling clap v2.34.0
   Compiling env_logger v0.8.4
   Compiling libusb1-sys v0.5.0
   Compiling which v3.1.1
   Compiling minimal-lexical v0.2.1
   Compiling syn v1.0.107
   Compiling nom v7.1.3
   Compiling either v1.8.1
   Compiling bindgen v0.63.0
   Compiling which v4.4.0
   Compiling cexpr v0.6.0
   Compiling cmake v0.1.49
   Compiling usb-compat-01-sys v0.2.3
   Compiling nfc1-sys v0.3.1
    Checking nfc1 v0.5.0 (/Users/username/rs-nfc1)
error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/lib.rs:2:2
  |
2 |     size_t,
  |     ^^^^^^ no `size_t` in the root

error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/target/info.rs:2:5
  |
2 | use nfc1_sys::size_t;
  |     ^^^^^^^^^^^^^^^^ no `size_t` in the root
  |
help: consider importing this unresolved item instead
  |
2 | use crate::size_t;
  |     ~~~~~~~~~~~~~~

error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/context.rs:2:16
  |
2 | use nfc1_sys::{size_t, nfc_context, nfc_connstring, nfc_init, nfc_exit, nfc_list_devices};
  |                ^^^^^^ no `size_t` in the root
  |
help: consider importing this unresolved item instead
  |
2 | use nfc1_sys::{crate::size_t;
  |                ~~~~~~~~~~~~~~

error[E0432]: unresolved import `nfc1_sys::size_t`
  --> src/device.rs:18:2
   |
18 |     size_t,
   |     ^^^^^^ no `size_t` in the root
   |
help: consider importing this unresolved item instead
   |
18 |     crate::size_t;
   |

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nfc1` due to 4 previous errors
@alexrsagen
Copy link
Owner

Hi @riklus, I don't see what target you are using.

I've compiled and ran this successfully on macOS with XCode build tools (no homebrew!), a Windows computer with MSVC and Linux with gcc (Debian-based distros).

Could you post the output of:

rustc -vV | sed -n 's|host: ||p'

Also, what compiler toolchains do you have installed? alexrsagen/rs-nfc1-sys#4 seems related.

@riklus
Copy link
Author

riklus commented Feb 16, 2023

The target is: x86_64-apple-darwin
About my toolchains I have:
Xcode command line tools
gcc+gdb+make+cmake from homebrew

Other tools installed through homebrew are: cocoapods, coreutils
Maybe hombrew is the problem.

I noticed another issue using nfc1 with --no-default-features. During compilation:

error[E0463]: can't find crate for `cmake`
 --> /Users/username/.cargo/registry/src/github.com-1ecc6299db9ec823/nfc1-sys-0.3.1/build.rs:2:1
  |
2 | extern crate cmake;
  | ^^^^^^^^^^^^^^^^^^^ can't find crate

Maybe are they all related to some misconfiguration of homebrew's toolchains?

@riklus
Copy link
Author

riklus commented Feb 16, 2023

I tried running the same command cargo check while setting the PATH variable like this:
export PATH=/bin/:/usr/bin/:/Users/username/.cargo/bin/:/Applications/CMake.app/Contents/bin

Using: cmake-3.26.0-rc3-macos-universal.dmg from cmake.org

But I get the same error.

@alexrsagen
Copy link
Owner

alexrsagen commented Feb 16, 2023

Maybe are they all related to some misconfiguration of homebrew's toolchains?

I think the issue might be having a gcc and libc from both homebrew and XCode, but I'm not sure.

Could you try having only XCode and cmake or only homebrew gcc / libc and cmake installed?

Regarding running with --no-default-features, this removes the vendored feature, which is only what you want if you need to link a system-installed libnfc dynamically (and not build it from source and link statically).

@riklus
Copy link
Author

riklus commented Feb 16, 2023

I tried the --no-default-features to avoid compilation of libnfc but it threw an even uglier message:

error[E0463]: can't find crate for `cmake`
 --> /Users/username/.cargo/registry/src/github.com-1ecc6299db9ec823/nfc1-sys-0.3.1/build.rs:2:1
  |
2 | extern crate cmake;
  | ^^^^^^^^^^^^^^^^^^^ can't find crate

Which is strange... how can the cmake create not be found?

About compiling with only gcc/libc on Mac I think isn't possible because it switches to clang and I honestly don't know how to force the compilation with gcc.

@riklus
Copy link
Author

riklus commented Feb 17, 2023

I also tried to run cargo check on codespaces and I get the same error:

    Updating crates.io index
  Downloaded lazy_static v1.4.0
  Downloaded glob v0.3.1
  Downloaded vec_map v0.8.2
  Downloaded version_check v0.9.4
  Downloaded unicode-ident v1.0.6
  Downloaded unicode-width v0.1.10
  Downloaded regex-syntax v0.6.28
  Downloaded regex v1.7.1
  Downloaded which v3.1.1
  Downloaded which v4.4.0
  Downloaded textwrap v0.11.0
  Downloaded atty v0.2.14
  Downloaded cmake v0.1.49
  Downloaded libloading v0.7.4
  Downloaded pkg-config v0.3.26
  Downloaded memchr v2.5.0
  Downloaded either v1.8.1
  Downloaded clap v2.34.0
  Downloaded bindgen v0.63.0
  Downloaded quote v1.0.23
  Downloaded nom v7.1.3
  Downloaded env_logger v0.8.4
  Downloaded usb-compat-01-sys v0.2.3
  Downloaded nfc1-sys v0.3.1
  Downloaded libusb1-sys v0.5.0
  Downloaded libc v0.2.139
  Downloaded ansi_term v0.12.1
  Downloaded log v0.4.17
  Downloaded peeking_take_while v0.1.2
  Downloaded cc v1.0.79
  Downloaded humantime v2.1.0
  Downloaded clang-sys v1.4.0
  Downloaded bitflags v1.3.2
  Downloaded cfg-if v1.0.0
  Downloaded cexpr v0.6.0
  Downloaded cexpr v0.4.0
  Downloaded bindgen v0.58.1
  Downloaded syn v1.0.107
  Downloaded strsim v0.8.0
  Downloaded nom v5.1.2
  Downloaded termcolor v1.2.0
  Downloaded minimal-lexical v0.2.1
  Downloaded shlex v1.1.0
  Downloaded rustc-hash v1.1.0
  Downloaded proc-macro2 v1.0.51
  Downloaded lazycell v1.3.0
  Downloaded aho-corasick v0.7.20
  Downloaded 47 crates (3.8 MB) in 0.56s
   Compiling libc v0.2.139
   Compiling memchr v2.5.0
   Compiling glob v0.3.1
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.51
   Compiling clang-sys v1.4.0
   Compiling log v0.4.17
   Compiling quote v1.0.23
   Compiling unicode-ident v1.0.6
   Compiling aho-corasick v0.7.20
   Compiling cc v1.0.79
   Compiling version_check v0.9.4
   Compiling regex-syntax v0.6.28
   Compiling nom v5.1.2
   Compiling libloading v0.7.4
   Compiling regex v1.7.1
   Compiling bitflags v1.3.2
   Compiling pkg-config v0.3.26
   Compiling atty v0.2.14
   Compiling shlex v1.1.0
   Compiling peeking_take_while v0.1.2
   Compiling rustc-hash v1.1.0
   Compiling lazy_static v1.4.0
   Compiling unicode-width v0.1.10
   Compiling lazycell v1.3.0
   Compiling textwrap v0.11.0
   Compiling strsim v0.8.0
   Compiling ansi_term v0.12.1
   Compiling bindgen v0.58.1
   Compiling vec_map v0.8.2
   Compiling humantime v2.1.0
   Compiling termcolor v1.2.0
   Compiling clap v2.34.0
   Compiling env_logger v0.8.4
   Compiling cexpr v0.4.0
   Compiling libusb1-sys v0.5.0
   Compiling which v3.1.1
   Compiling syn v1.0.107
   Compiling minimal-lexical v0.2.1
   Compiling nom v7.1.3
   Compiling either v1.8.1
   Compiling bindgen v0.63.0
   Compiling which v4.4.0
   Compiling usb-compat-01-sys v0.2.3
   Compiling cexpr v0.6.0
   Compiling cmake v0.1.49
   Compiling nfc1-sys v0.3.1
    Checking nfc1 v0.5.0 (/workspaces/rs-nfc1)
error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/lib.rs:2:2
  |
2 |     size_t,
  |     ^^^^^^ no `size_t` in the root

error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/target/info.rs:2:5
  |
2 | use nfc1_sys::size_t;
  |     ^^^^^^^^^^^^^^^^ no `size_t` in the root
  |
help: consider importing this unresolved item instead
  |
2 | use crate::size_t;
  |     ~~~~~~~~~~~~~~

error[E0432]: unresolved import `nfc1_sys::size_t`
 --> src/context.rs:2:16
  |
2 | use nfc1_sys::{size_t, nfc_context, nfc_connstring, nfc_init, nfc_exit, nfc_list_devices};
  |                ^^^^^^ no `size_t` in the root
  |
help: consider importing this unresolved item instead
  |
2 | use nfc1_sys::{crate::size_t;
  |                ~~~~~~~~~~~~~~

error[E0432]: unresolved import `nfc1_sys::size_t`
  --> src/device.rs:18:2
   |
18 |     size_t,
   |     ^^^^^^ no `size_t` in the root
   |
help: consider importing this unresolved item instead
   |
18 |     crate::size_t;
   |

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nfc1` due to 4 previous errors

My codespace is:

Linux codespaces-7e2e94 5.4.0-1103-azure #109~18.04.1-Ubuntu SMP Wed Jan 25 20:53:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
cargo 1.67.1 (8ecd4f20a 2023-01-10)
rustc 1.67.1 (d5a82bbd2 2023-02-07)
target: x86_64-unknown-linux-gnu

@lerela
Copy link

lerela commented Mar 8, 2023

Exactly the same errors on Ubuntu:

rustc 1.67.1 (d5a82bbd2 2023-02-07)

Linux 6.0.12-76060006-generic #202212290932~1674139725~22.04~ca93ccf SMP PREEMPT_DYNAMIC Thu J x86_64 x86_64 x86_64 GNU/Linux

❯ rustc -vV | sed -n 's|host: ||p'
x86_64-unknown-linux-gnu

@alexrsagen
Copy link
Owner

Sorry about the delay in response from me here, I will try to reproduce the issue on Ubuntu/macOS and see if I can fix this.

@lerela
Copy link

lerela commented Mar 8, 2023

I can confirm that it compiles and successfully runs with 0.5.1. Thanks @alexrsagen!

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

3 participants