Linker error (Linux Mint 22.2)

I am running Linux Mint 22.2 (x86_64), rustup 1.26.0, cargo 1.92.0.

I decided to play around with this project (GitHub - PerroEngine/Perro: πŸ• Perro β€” A game engine written in Rust that utilizes a unique transpilation system that allows developers to write in high level languages for quick iteration and ease of use, while achieving native performance.) and when I try to build the tool I get the following:

$ cargo run -p perro_dev
warning: unused config key build.RUSTFLAGS in /home/eda/build/Perro/.cargo/config.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package: /home/eda/build/Perro/perro_core/Cargo.toml
workspace: /home/eda/build/Perro/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package: /home/eda/build/Perro/perro_dev/Cargo.toml
workspace: /home/eda/build/Perro/Cargo.toml
warning: /home/eda/build/Perro/perro_dev/Cargo.toml: unused manifest key: target.cfg(windows).rustflags
Compiling libc v0.2.178
Compiling proc-macro2 v1.0.103
Compiling quote v1.0.42
Compiling smallvec v1.15.1
error: linking with rust-lld failed: exit status: 1
|
= note: "rust-lld" "-flavor" "gnu" "/tmp/rustclcaqxV/symbols.o" "<2 object files omitted>" "--as-needed" "-Bstatic" "/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-,libpanic_unwind-,libobject-,libmemchr-,libaddr2line-,libgimli-,libcfg_if-,librustc_demangle-,libstd_detect-,libhashbrown-,librustc_std_workspace_alloc-,libminiz_oxide-,libadler2-,libunwind-,liblibc-,librustc_std_workspace_core-,liballoc-,libcore-,libcompiler_builtins-*}.rlib" "-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustclcaqxV/raw-dylibs" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/eda/build/Perro/target/debug/build/quote-03d3df1af8178ab4/build_script_build-03d3df1af8178ab4" "--gc-sections" "-pie" "-z" "relro" "-z" "now"
= note: some arguments are omitted. use --verbose to show all linker arguments
= note: rust-lld: error: unable to find library -lgcc_s
rust-lld: error: unable to find library -lutil
rust-lld: error: unable to find library -lrt
rust-lld: error: unable to find library -lpthread
rust-lld: error: unable to find library -lm
rust-lld: error: unable to find library -ldl
rust-lld: error: unable to find library -lc

Any idea how to resolve this?

Thanks,
/Ed

Can you build C/C++ programs there? it really looks as if your Linux doesn't include even the most basic development packages…

Yes, I can compile C++ programs.

Have you tried cargo clean and then again cargo run -p perro_dev?

I did not but the same error occurs after I run that command.

Interestingly, "hello-rust" works:

$ cargo run
Finished dev profile [unoptimized + debuginfo] target(s) in 1.15s
Running target/debug/hello-rust
Hello, world!

So, I guess I will contact the Perro developer

Do you have a build.rs in your project? The missing libs are pretty standard, and are almost certainly available on your system if you can build C++ apps, so possibly there's a build.rs that's changing lib include paths.

There is one. I'm not sure I understand it well though.
There are #[cfg[target_os = "windows"] sections but nothing specific for Linux.

I was going to use Perro to learn Rust :slight_smile:

Do you have any .cargo/config.toml in your home dir or the project dir that sets the linker to rust-lld? Using a bare linker like rust-lld directly as linker doesn't work on Unix targets. It needs to be wrapped by gcc oe clang as linker driver telling it things like where to find system libraries. Given that rustc now uses lld by default on x86_64-unknown-linux-gnu (or rather tells gcc/clang to use it), you should remove the explicit setting of the linker.

1 Like

SOLVED

Yes, after talking to the repository owner the issue has been resolved by removing the files.