Rust-bindgen: Error while loading shared libraries

Created on 8 Feb 2018  Â·  12Comments  Â·  Source: rust-lang/rust-bindgen

With bindgen installed via cargo install bindgen and rustup installed via the standard curl | bash method:

# rustup --version
rustup 1.10.0 (c6a8f7c60 2018-01-25)

# cargo --version
cargo 0.24.0 (45043115c 2017-12-05)

# bindgen
bindgen: error while loading shared libraries: libproc_macro-6572f0cb64bf7b5a.so: cannot open shared object file: No such file or directory

# env LD_LIBRARY_PATH=/home/stuartnelson/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/ bindgen
error: The following required arguments were not provided:
    <header>
USAGE:
    bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>...
For more information try --help

It seems like the .so is in a standard location, so I think it's incorrect that I have to manually specify it?

Most helpful comment

bindgen as a binary depends on internal rustc crates. Therefore you cannot run it directly, but instead must run it using rustup run and you must specify the same toolchain that you used to install it originally. If you ever update that toolchain then you must reinstall bindgen.

All 12 comments

I'm having similare problems on Mac OS:

➜  examples git:(master) ✗ rustup --version
rustup 1.9.0 (57fc3c087 2018-01-04)
➜  examples git:(master) ✗ cargo --version
cargo 0.24.0 (45043115c 2017-12-05)
➜  examples git:(master) ✗ bindgen
dyld: Library not loaded: @rpath/libproc_macro-135818a8fe3a20d3.dylib
  Referenced from: /Users/fl-macbook-retina/.cargo/bin/bindgen
  Reason: image not found
[1]    46570 abort      bindgen

cargo run +stable bindgen should help I think... I suspect this is due to the recent syn update, cc @Eijebong.

I'm not sure what you're suggesting @emilio as bindgen was installed and ran using cargo install bindgen as a global tool. Is this not supposed to work? Is there a stable option for cargo install that I'm not aware of?

@TheKnarf

I suppose the right command would be rustup run stable bindgen if you install via cargo install bindgen with default stable compiler.

Ah, that is unexpected

bindgen as a binary depends on internal rustc crates. Therefore you cannot run it directly, but instead must run it using rustup run and you must specify the same toolchain that you used to install it originally. If you ever update that toolchain then you must reinstall bindgen.

This isn't described at all in the documentation. It should be updated with what @retep998 and @Dushistov said.

Bisected to

6899c275ee0ab0687ec66c490ddd1a76f8223513 is the first bad commit
commit 6899c275ee0ab0687ec66c490ddd1a76f8223513
Author: Bastien Orivel <[email protected]>
Date:   Tue Jan 23 00:12:58 2018 +0100

    Bump quote to 0.4

I think we should revert this commit.

@alexcrichton confirmed that proc_macro2 depends on rustc internal libraries. He says that we could potentially put that behind a default-on feature, and that bindgen could disable it. Once that happens, we can try using the new quote and proc_macro2 again.

We had a similar problem with cbindgen with the update to the latest syn. I filed rust-lang/rust#47931 for it, in case anybody is interested in following along with the upstream issue.

I guess this topic can be revisited, now that syn 0.5 released with default-on proc-macro feature: https://github.com/dtolnay/quote/blob/45d3801fde811d432955100220ead1ff2ba27edd/Cargo.toml#L20

Yep, but this is the same as for cssparser, we need to try and coordinate everything.
Unless you want to do it, it's going to have to wait until at least Tuesday as I don't really have the time for that right now.

Was this page helpful?
0 / 5 - 0 ratings