Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compile with pulseaudio backend fails #229

Closed
mfeif opened this issue May 31, 2018 · 4 comments
Closed

Docker compile with pulseaudio backend fails #229

mfeif opened this issue May 31, 2018 · 4 comments

Comments

@mfeif
Copy link

mfeif commented May 31, 2018

I put in the command:

docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features pulseaudio-backend

eventually got:
note: /usr/bin/ld: cannot find -lpulse /usr/bin/ld: cannot find -lpulse-simple collect2: error: ld returned 1 exit status

On a lark, I logged into the docker image and installed pulseaudio -dev libraries via apt, but no difference. I poked around in the source and the toml files a bit, but I don't know what I'm doing.

Thanks!

@kingosticks
Copy link
Contributor

Sounds like #142 which despite being closed sounds like it's still an issue.

@mfeif
Copy link
Author

mfeif commented May 31, 2018

Good catch; sorry, I should have searched more thoroughly.

If I restrict my additional libraries to the armhf, I'm able to install them:
apt-get install libpulse-dev:armhf
Works.

But I can't compile still:

docker run -v /tmp/librespot-build:/build librespot-cross cargo build --verbose --release --target arm-unknown-linux-gnueabihf --no-default-features --features pulseaudio-backend`
Fails:
`note: /usr/lib/gcc-cross/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpulse
          /usr/lib/gcc-cross/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpulse-simple
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `librespot`.

Caused by:
  process didn't exit successfully: `rustc --crate-name librespot src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg feature="librespot-playback" --cfg feature="pulseaudio-backend" -C metadata=af05f7ac2779943a -C extra-filename=-af05f7ac2779943a --out-dir /build/arm-unknown-linux-gnueabihf/release/deps --target arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc -L dependency=/build/arm-unknown-linux-gnueabihf/release/deps -L dependency=/build/release/deps --extern rpassword=/build/arm-unknown-linux-gnueabihf/release/deps/librpassword-caead108b793ad31.rlib --extern tokio_io=/build/arm-unknown-linux-gnueabihf/release/deps/libtokio_io-b02e80f9841d3c0b.rlib --extern librespot_protocol=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_protocol-636c736aa5a701e2.rlib --extern rand=/build/arm-unknown-linux-gnueabihf/release/deps/librand-28e6cd3eee2b14b3.rlib --extern getopts=/build/arm-unknown-linux-gnueabihf/release/deps/libgetopts-6677b664d415c70e.rlib --extern librespot_metadata=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_metadata-567d9797ec932d39.rlib --extern env_logger=/build/arm-unknown-linux-gnueabihf/release/deps/libenv_logger-67e01bea17ca18a2.rlib --extern serde_derive=/build/release/deps/libserde_derive-ea88eb7fee4e7521.so --extern librespot_connect=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_connect-5d674dc011b746a8.rlib --extern librespot_playback=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_playback-327f73b850132341.rlib --extern tokio_core=/build/arm-unknown-linux-gnueabihf/release/deps/libtokio_core-6300623937f81323.rlib --extern futures=/build/arm-unknown-linux-gnueabihf/release/deps/libfutures-57a5f5a41c6692da.rlib --extern log=/build/arm-unknown-linux-gnueabihf/release/deps/liblog-f382f336e103443e.rlib --extern hyper=/build/arm-unknown-linux-gnueabihf/release/deps/libhyper-d9f7a2519cfeb931.rlib --extern crypto=/build/arm-unknown-linux-gnueabihf/release/deps/libcrypto-7349a6d7444bd56b.rlib --extern serde=/build/arm-unknown-linux-gnueabihf/release/deps/libserde-cb3b4c938aef3ea6.rlib --extern num_bigint=/build/arm-unknown-linux-gnueabihf/release/deps/libnum_bigint-a72be0246fde335f.rlib --extern protobuf=/build/arm-unknown-linux-gnueabihf/release/deps/libprotobuf-3092364993ca4c1b.rlib --extern serde_json=/build/arm-unknown-linux-gnueabihf/release/deps/libserde_json-2bfd44e7f91e1206.rlib --extern tokio_signal=/build/arm-unknown-linux-gnueabihf/release/deps/libtokio_signal-883ad4e518a32fa9.rlib --extern librespot_core=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_core-6b9816d127f60634.rlib --extern base64=/build/arm-unknown-linux-gnueabihf/release/deps/libbase64-6b68909953043529.rlib --extern librespot_audio=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot_audio-a4bb241251c72b44.rlib --extern url=/build/arm-unknown-linux-gnueabihf/release/deps/liburl-948ea0ca96ba6781.rlib --extern librespot=/build/arm-unknown-linux-gnueabihf/release/deps/liblibrespot-db91d85429936b82.rlib -L native=/build/arm-unknown-linux-gnueabihf/release/build/rust-crypto-83dc7834eb2b79c8/out` (exit code: 101)

@mfeif
Copy link
Author

mfeif commented Jun 12, 2018

As per my comments on #142, I was able to compile librespot with the patch referenced there, but it wouldn't work on my device, which was based on much older libraries.

I dug in a little deeper, and have found that this Dockerfile worked for me:

FROM debian:stretch

RUN dpkg --add-architecture armhf
RUN apt-get update

RUN apt-get install -y curl git build-essential crossbuild-essential-armhf
#RUN apt-get install -y libasound2-dev libasound2-dev:armhf
RUN apt-get install -y libpulse-dev:armhf

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin/:${PATH}"
RUN rustup target add arm-unknown-linux-gnueabihf

RUN mkdir /.cargo && \
    echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' > /.cargo/config

RUN mkdir /build && \
    mkdir /pi-tools && \
    curl -L https://github.com/raspberrypi/tools/archive/648a6eeb1e3c2b40af4eb34d88941ee0edeb3e9a.tar.gz | tar xz --strip-components 1 -C /pi-tools

ENV CARGO_TARGET_DIR /build
ENV CARGO_HOME /build/cache

ADD . /src
WORKDIR /src
CMD ["/src/contrib/docker-build-armv6hf-pulse.sh"]

You see that I stripped out just about everything that wasn't armhf oriented, but the key difference that led to a passing build seemed to be that I removed libpulse-dev in favor of only the :armhf variation. I also changed ending build script line to use the arm6hf version of the script, which you can see I modified to be just about pulse:

#!/usr/bin/env bash

# Snipped and tucked from https://github.com/plietar/librespot/pull/202/commits/21549641d39399cbaec0bc92b36c9951d1b87b90
# and further inputs from https://github.com/kingosticks/librespot/commit/c55dd20bd6c7e44dd75ff33185cf50b2d3bd79c3

set -eux
# Get alsa lib and headers
ALSA_VER="1.0.25-4"
DEPS=( \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/a/alsa-lib/libasound2_${ALSA_VER}_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/a/alsa-lib/libasound2-dev_${ALSA_VER}_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/pulseaudio_11.1-5+b2_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/pulseaudio-utils_11.1-5+b2_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/pulseaudio-module-zeroconf_11.1-5+b2_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/libpulse0_11.1-5+b2_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/libpulse-mainloop-glib0_11.1-5+b2_armhf.deb" \
  "http://mirrordirector.raspbian.org/raspbian/pool/main/p/pulseaudio/libpulse-dev_11.1-5+b2_armhf.deb"
)

# Collect Paths
SYSROOT="/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot"
GCC="/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
GCC_SYSROOT="$GCC/gcc-sysroot"


export PATH=/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/:$PATH

# Link the compiler
export TARGET_CC="$GCC/arm-linux-gnueabihf-gcc"

# Create wrapper around gcc to point to rpi sysroot
echo -e '#!/bin/bash' "\n$TARGET_CC --sysroot $SYSROOT \"\$@\"" > $GCC_SYSROOT
chmod +x $GCC_SYSROOT

# Add extra target dependencies to our rpi sysroot
for path in "${DEPS[@]}"; do
  curl -OL $path
  dpkg -x $(basename $path) $SYSROOT
done

# i don't why this is neccessary
# ln -s ld-linux.so.3 $SYSROOT/lib/ld-linux-armhf.so.3

# point cargo to use gcc wrapper as linker
echo -e '[target.arm-unknown-linux-gnueabihf]\nlinker = "gcc-sysroot"' > /.cargo/config

# Build
#cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "pulse-backend"

(But I don't actually think this script runs, because we have to run the second command after building the docker image as per the instructions in the wiki...) I think I added in a lot more libraries there than are necessary for compilation; I was just in trial and error, not fully knowing how cross-compilation works. I should think that the non -dev debs could be removed. (But again, I'm not even sure that this script runs :-/ )

I then built and compiled with these commands:

docker build -t lr-pulse -f contrib/Dockerfile.pulse .
docker run -v /tmp/lr-build:/build lr-pulse cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features pulse-backend

I presume that one could re-enable ALSA and get BOTH backends running, but I haven't done that yet.

I'm writing this up in case it helps others; meanwhile, I suppose an arch-specific Docker build process might be warranted in this case? I could refine what I've done above and make a pull request...

@sashahilton00
Copy link
Member

@mfeif if you're still up for it, a PR for arch specific docker would be good to have.

@librespot-org librespot-org locked and limited conversation to collaborators Feb 23, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants