How to pass cargo linker args?


I need pass to linker args,
i put in my ~/.cargo/config:

linker = "arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf"


i get error:
error: could not exec the linker `/home/chessnokov/arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf`: No such file or directory

then try:

linker = “arm-linux-gnueabihf-gcc “-Xlinker” “-rpath=/usr/lib/arm-linux-gnueabihf””

same error


Sorry for bringing this to the top but, since it shows up on Google, I think it merits at least one answer:

Cargo and the TOML language aren’t as loose about the difference between a string and a list as shell scripting is. If you actually used the ["array", "syntax"], you’d have gotten an error from Cargo about how it expected a string.

I’ve checked the docs and can’t find any evidence that adding custom arguments is supported directly, so you’ll have to write a simple wrapper script like this and then point ~/.cargo/config at that instead.

exec arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf "$@"


linker = “arm-linux-gnueabihf-gcc"
rustflags = [”-Clink-args=-Xlinker -rpath=/usr/lib/arm-linux-gnueabihf"]


Another example can be seen here: