I’m trying to cross-compile my application from a Linux-x86 host to a Linux-armv7 target. As far as I can tell I have everything set up correctly (well partially) since I can cross compile and execute an application with no native dependencies. The problem comes when I add Diesel with a Postgresql backend. When I do that, I see the following link error:
error: linking with `arm-linux-gnueabihf-gcc` failed: exit code: 1 | = note: "arm-linux-gnueabihf-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/gamroth/.rustup/toolchains/stable-x86_64-unkn own-linux-gnu/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" .... lots of snipped text here .... = note: /usr/lib/x86_64-linux-gnu/libpq.so: file not recognized: File format not recognized collect2: error: ld returned 1 exit status
I’m confused about this part – why is the compiler looking at /usr/lib/x86_64-linux-gnu/ for libraries instead of /usr/lib/arm-linux-gnueabihf/. I’ve installed the armv7 dependencies I need to that location.
A couple of things I’ve tried:
Standard cross compile build:
$ cargo build --target=armv7-unknown-linux-gnueabihf
Setting the link path as an env variable:
$ RUSTFLAGS=’-L /usr/lib/arm-linux-gnueabihf/’ cargo build --target=armv7-unknown-linux-gnueabihf
Both of these give me the same error message from above.
Is there something I’m doing wrong here? I’m not even sure why I need the shared library installed to compile. I’m especially not sure why the compiler/linker is even looking at /usr/lib/x86_64-linux-gnu for libraries and how I can change that.