diwic / alsa-sys

Rust raw FFI bindings for ALSA
MIT License
15 stars 11 forks source link

Library forces use of /usr/lib #3

Closed lyneca closed 4 years ago

lyneca commented 4 years ago

I'm attempting to cross-compile a project onto Raspberry Pi. It has alsa-sys as a dependency, and the linker fails when trying to link in libutil.so. For some reason, it's pulling it from /usr/lib instead of the ARM gcc library.

In target/arm-unknown-linux-gnueabihf/release/build/alsa-sys-2d409b6482724cb8/output, this option is set:

cargo:rustc-link-search=native=/usr/lib

Changing this line to the following fixes the build:

cargo:rustc-link-search=native=[pi build tools dir]/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/usr/lib/

(where [pi build tools dir] is the raspberry pi cross-compile build tools).

I'm not very familiar with how Rust's build/compile system works - is this an issue with this repository?

diwic commented 4 years ago

Hi!

So I think you're the first asking for cross compilation of alsa-sys, but I also maintain libdbus-sys which a few people have tried to cross compile, to the extend that I have written a guide here with their collected information. I see no reason why it shouldn't work as well for alsa-sys, just replace:

...something like that. And we encountered the "absolute path" issue with libdbus as well, I think it was some file on the Raspberry pi rootfs that contained the absolute paths IIRC.

lyneca commented 4 years ago

Linking off a rPi rootfs is such a great idea - thanks!

diwic commented 4 years ago

Closing due to inactivity, and because I think this is a general Rust cross-compile issue rather than an issue with this repository. Feel free to reopen (or start a new issue) if this is wrong.