Cross compilation: set target linker search path

I am trying to cross compile x86 (and arm) targets. Installed necessary targets and configured config.toml with required linker config.

However, build fails as it cannot find the 'linker'.

If I manually set env variable PATH in the shell (which has linker is avaiable), then build works fine.

So, wondering how to achieve the same via config.toml.

So far I tried, setting rustflags, rustc-link-search for the mentioned target. But doesn't work. Appreciate the help.

rustflags=["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc", "-L", "/usr/x86-10.3-glibc-2.34/bin"]
rustc-link-search = { all = "/usr/x86-10.3-glibc-2.34/bin" }

If you are compiling on a macOS do you need to install a couple of additional packages: Cross-compiling Rust From Mac to Linux | by Merlin Fuchs | Better Programming

Posting the build command and error for better understanding of the problem:

Build command: cargo build --verbose --target x86_64-unknown-linux-gnu

error: linker x86_64-xxxx_buildroot-linux-gnu-gcc not found
= note: No such file or directory (os error 2)

error: could not compile hello (bin "hello") due to previous error

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.