Cross compiling with gstreamer-1.0 on debian (amd64 hosting armhf libs)

hi!
i'd like to cross compile an app linking to gstreamer-1.0 on debian.

the trivial hello world already cross compiles successfully ( i guess my rust target chain is working alright ).

however using cargo build fails with /usr/lib/gcc-cross/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstreamer-1.0

my guess is that ld is trying to find the libs in /usr/arm-linux-gnueabihf/lib when libgstreamer-1.0.so.0 is actually located in /usr/lib/arm-linux-gnueabihf.

what i'd like to do is pass an additianl -L flag to cargo but can't figure out how to do so.

things i tried so far:


RUSTFLAGS="-L/usr/lib/arm-linux-gnueabihf" cargo build --target=armv7-unknown-linux-gnueabihf


cat ~/.cargo/config

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
rustc-link-search = ["/usr/lib/arm-linux-gnueabihf"]

fails with /usr/lib/gcc-cross/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstreamer-1.0


LD_LIBRARY_PATH=/usr/lib/arm-linux-gnueabihf cargo build --target=armv7-unknown-linux-gnueabihf


cat Cargo.toml

[package]
name = "foo"
version = "0.1.0"
authors = ["m"]
build = "build.rs"

[dependencies]
gstreamer = "0.6.333"

cat build.rs

fn main(){println!("cargo:rustc-link-search=native=/usr/lib/arm-linux-gnueabihf");}

none of those worked. i'm kind of running out of guesses here :smiley:

help is much appreciated!

Obligatory question: Can you build a C program for armhf that links to gstreamer? If yes, then you should be able to build a Rust program that links to gstreamer. If not, then you may be missing some C stuff (the shared library for instance)

cat build.rs

Hmm, this should have worked.

  • Did the build script actually run? Is build = "build.rs" set in Cargo.toml? Is there an output (text) file with the "cargo:rustc-link-search=native=/usr/lib/arm-linux-gnueabihf" string in it somewhere in the target directory?
  • Is the armhf libgstreamer.so actually in /usr/lib/arm-linux-gnueabihf? (Is the proper (apt-get?) package installed?
  • You should the linker arguments that rustc passes to arm-linux-gnueabihf-gcc. The error message should show them; or you could use cargo rustc --target $T -- -Z print-link-args. Is the -L flag among the linker flags?

is cargo relying on a working pkg-config?
for troubleshooting i started out with a fresh rootfs bootstrapped from ubuntu 16.04 where arm-linux-gnueabihf-pkg-config is available and no it gets linked properly.

is cargo relying on a working pkg-config?

That's not up to Cargo but it's the job of the crate that wraps a C library. And, IIRC, the pkg-config crate which is used to call pkg-config from build scripts doesn't support cross compilation setups; it didn't prefix the pkg-config command IIRC. At least it didn't last time I checked (months ago).