Skip to content
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

does not start on raspberry pi 3 b+ with latest raspberry pi os 64 bit #1053

Open
meeeeeeeeeeeeeeee opened this issue Feb 6, 2022 · 19 comments

Comments

@meeeeeeeeeeeeeeee
Copy link

using systemctl --user start spotifyd.service does nothing

starting spotifyd with ./spotifyd --no-daemon I get ./spotifyd: error while loading shared libraries: libsystemd.so.0: cannot open shared object file: No such file or directory

checking to see if that file exists says the one for aarch64 is there but the one for armhf is missing

pi@raspberry-pi:~ $ ls -l /lib/aarch64-linux-gnu/libsystemd.so.0*
lrwxrwxrwx 1 root root 20 Jul 13 2021 /lib/aarch64-linux-gnu/libsystemd.so.0 -> libsystemd.so.0.30.0
-rw-r--r-- 1 root root 742816 Jul 13 2021 /lib/aarch64-linux-gnu/libsystemd.so.0.30.0
pi@raspberry-pi:~ $ ls -l /lib/arm-linux-gnueabihf/libsystemd.so.0*
ls: cannot access '/lib/arm-linux-gnueabihf/libsystemd.so.0*': No such file or directory

trying to install the armhf version of systemd fails because it wants to remove the 64 bit version and can't

a fix for this is to have precompiled binaries for armhf and aarch64

@eladyn
Copy link
Member

eladyn commented Feb 6, 2022

Hi!

I have not much experience in this matter, but I found out that only the -default and -full releases are linking to libsystemd (AFAICT). So you might get further by trying the -slim version.

Apart from that, I don't know how feasible it is in general to execute binaries compiled for armhf on aarch64. However, you can of course build spotifyd yourself directly on the platform.

Hope this helps!

@waldeckmatheus
Copy link

waldeckmatheus commented Apr 20, 2022

Hello, here i found the same problem, i wasn't able to do so, downloaded spotifyd but "nothing" happens when running: spotifyd --no-daemon

I "solved" this by doing the following:

Compiled it with aarch64 (arm64v8), in a RPI 3 model B, OS release Debian GNU/Linux 11 (bullseye).

If need to, you may try the following:
Before compile: installation of linux dependencies/libraries; increase swap from 100mb to 1024mb.

Important notes: It takes some time to compile and raspberry pi may get warm. Here, beyond the mini cooler, it was added a "table fan", just under precaution.

Installation of dependecies / libraries

sudo apt install build-essential libasound2-dev libssl-dev libpulse-dev libdbus-1-dev -y
sudo apt install cargo -y

Increase for Swap Memory, needs to reboot after done

sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
sudo dphys-swapfile swapon

To compile

Inside source folder, it was used the following command, not checked about PKG_CONFIG_PATH, but it was compiling:

sudo bash -c 'PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu --release > log.txt 2>&1 & disown'

To follow the log output

The process may get some time to be done, it can be checked log.txt, inside source folder, to know what is happening, using: tail -f log.txt

After compiled

Executable can be found on: ./target/aarch64-unknown-linux-gnu/release/spotifyd

It was used this following links to specify the configuration on "/home/pi/.config/spotifyd/spotifyd.conf", of how it should start, and audio device to play sound:
https://github.com/Spotifyd/spotifyd/wiki/Installing-on-a-Raspberry-Pi
https://spotifyd.github.io/spotifyd/config/File.html

Others informations

It was used the following url to get some ideas of how do some parts: https://github.com/Spotifyd/spotifyd/wiki/Cross-Compiling-on-Ubuntu

Good lucky.

@georgefst
Copy link

georgefst commented Sep 4, 2022

Thanks @waldeckmatheus, I'll have to try that. I'd been hoping that by the time I moved to Bullseye, there'd be AArch64 binaries available. But I forgot to check before I upgraded yesterday.

I also haven't had any luck with cross-compiling. Spotifyd does have a cross-compilation guide, but to be honest it's really just a generic Rust cross-compilation guide.

@HonestJohn61
Copy link

Hi @waldeckmatheus

Tried following your inctructions on my RPi4 running Ubuntu 22.04 but ended up with this:

error[E0658]: use of unstable library feature 'bool_to_option'
   --> src/config.rs:636:57
    |
636 |         .map(|path| Cache::new(Some(&path), audio_cache.then_some(&path), size_limit))
    |                                                         ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `spotifyd` due to previous error

I'm not competent to take this further I think

@eladyn
Copy link
Member

eladyn commented Oct 9, 2022

@HonestJohn61, see #1123 for this problem and a workaround.

@waldeckmatheusbelo
Copy link

waldeckmatheusbelo commented Oct 9, 2022

Hi @georgefst @HonestJohn61 @eladyn

I saw today the message and tried to compile again, after a long time since my last try to compile it by raspberry pi (without cross compiling).

Some points.

1. The version of rustc has updated over time, since last try

2. It's too slow to compile it from my RPI 3 model B

3. Compiling in container (docker)

  • It was able to finish the process of building, resulting in a binary spotifyd, using docker image "debian:latest", Debian GNU/Linux 11 (bullseye), with rustc 1.62.1 and cargo 1.62.1 (cross compiling, using container). I tested right now and it's working.
  • I will make some revisions (a lot of commands trying to adapt to got it, located in bash history) and try to share here the docker container image and Dockerfile source.
  • In this way, we can compile it in a isolated container without installing a lot of stuffs in our host machine, and targeting to aarch64/arm64v8.

@HonestJohn61
Copy link

@HonestJohn61, see #1123 for this problem and a workaround.

Thanks @eladyn - that resolved the issue for me.

@HonestJohn61
Copy link

Hi @georgefst @HonestJohn61 @eladyn

I saw today the message and tried to compile again, after a long time since my last try to compile it by raspberry pi (without cross compiling).

Some points.

1. The version of rustc has updated over time, since last try

2. It's too slow to compile it from my RPI 3 model B

3. Compiling in container (docker)

  • It was able to finish the process of building, resulting in a binary spotifyd, using docker image "debian:latest", Debian GNU/Linux 11 (bullseye), with rustc 1.62.1 and cargo 1.62.1 (cross compiling, using container). I tested right now and it's working.
  • I will make some revisions (a lot of commands trying to adapt to got it, located in bash history) and try to share here the docker container image and Dockerfile source.
  • In this way, we can compile it in a isolated container without installing a lot of stuffs in our host machine, and targeting to aarch64/arm64v8.

Thanks for the reply @waldeckmatheus. I'd already successfully compiled following your original post with the workaround suggested by @eladyn. BTW the compiling process didn't take too long or overheat my RPi4 (passively cooled in an aluminium heatsink case).

@waldeckmatheus
Copy link

1. Compiling into docker container

FROM debian:latest

#if you run it on host, make a backup to restore later.
RUN cat /dev/null > /etc/apt/sources.list

RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian-security bullseye-security main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye-updates main' >> /etc/apt/sources.list

RUN apt update

RUN apt install gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu git curl pkg-config -y
RUN apt purge rustc -y

RUN echo "(curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path)" > /install-rust.sh && \ 
    chmod 755 /install-rust.sh && \ 
    /install-rust.sh
RUN chmod a+x /root/.cargo/env && \
    /bin/sh -c /root/.cargo/env && \ 
    /root/.cargo/bin/rustup default 1.62.1

RUN /root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu

RUN echo '[target.aarch64-unknown-linux-gnu]' >> /root/.cargo/config
RUN echo 'linker="aarch64-linux-gnu-gcc"' >> /root/.cargo/config

RUN dpkg --add-architecture arm64
#RUN apt install crossbuild-essential-arm64 -y

RUN apt install libasound2-dev:arm64 libssl-dev:arm64 libpulse-dev:arm64 libdbus-1-dev:arm64 -y

RUN apt install libasound2-dev portaudio19-dev build-essential libpulse-dev libdbus-1-dev libssl-dev libudev-dev -y

RUN cd /root/ && git clone https://github.com/Spotifyd/spotifyd.git

RUN /bin/bash -c "source /root/.cargo/env \
    && cd /root/spotifyd/ \
    && PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu --release "

@HonestJohn61
Copy link

HonestJohn61 commented Oct 11, 2022

Hi, As I mentioned above, spotifyd is now running fine thanks to @waldeckmatheus and @eladyn. However, spotifyd doesn't register with playerctl, and I understand this may be to do with the dbus_mpris flag not being set when the binary was compiled. Does that sound right? How would I change the instructions I followed to address this issue? From what I've read I may also need dbus_keyring too, despite running spotifyd without credentials so as to allow guest users. I should also mention that it runs headless. Thanks

@eladyn
Copy link
Member

eladyn commented Oct 11, 2022

@HonestJohn61 You're right that you'll need to enable the dbus_mpris feature flag at the compile step. Just add a --features "dbus_mpris" behind --release.

Getting MPRIS to work on a headless system is not that easy, however.
If you need playerctl to work, you'd probably have to launch a session for spotifyd (e.g. via dbus-launch) and somehow get access to that from playerctl.
If you're happy with implementing your own solution and want to use the system bus (which is always there), you can use the newly introduced configuration option (dbus_type, #954) and tell spotifyd to connect to the system bus. You'll also need policies correctly set up, some examples can be found in this issue.

I should probably add a documentation page for that sometime. 😅 Hope you get it to work with that configuration!

@georgefst
Copy link

georgefst commented Oct 18, 2022

@waldeckmatheus Thanks! That worked for me (except MPRIS play/pause/next/previous is erroring out for some reason EDIT: this is fine - there's been a documented breaking change in the latest version).

I put that in to a file called Dockerfile then did the following from the same directory (I have no idea how to use Docker, so it's possible there's a much better way):

sudo docker build -t spotifyd-pi-aarch64 .
sudo docker save spotifyd-pi-aarch64 -o dist.tar
sudo chown gthomas dist.tar
tar xf dist.tar
cd a30c4ac40e5a5bfee7cce225b2f25edc20d660a8469035ac5c4c9d316342409e # found by searching the JSON files for "spotifyd"
tar xf layer.tar
scp root/spotifyd/target/aarch64-unknown-linux-gnu/release/spotifyd pi:.

@waldeckmatheusbelo
Copy link

waldeckmatheusbelo commented Oct 18, 2022

@georgefst Hi. Thank you for your reply. Here i found another way, may it apply.

1. About command docker build and copy of file to host machine

  • 1.1 When we use docker build (example "docker build -t spotifyd-pi-aarch64 ."), it's creating an image (like a screenshot) after all instructions executed we putted on "Dockerfile".
  • 1.2. We can run this image in a "isolated" container and pass some instruction to be executed, to rebuild, to copy, to install another package.
  • 1.3. docker run -v $(pwd):/mountedfolder -it spotifyd-pi-aarch64:latest /bin/cp /root/spotifyd/target/aarch64-unknown-linux-gnu/release/spotifyd /mountedfolder

2. About point 1.3

  • 2.1 In point 1.3, we are running this image in a container with shared volume like "pwd" (current directory) that will be used in copy of file "spotifyd" which exists into container to shared/mounted folder.
  • 2.2 it will execute command "cp" (copy) and put "spotifyd" binary into "mountedfolder" (host pwd directory).
  • 2.3 Later, will be stopped the container, because the only instruction was "copy file to" and it will finish.
  • 2.4 After done, spotifyd will be located in your current folder.

3. Others instructions

    1. docker container ls
    1. docker container rm <name_or_containerid>
    1. docker image ls
    1. docker image rm <name_or_imageid>

It's an awesome tool: https://docs.docker.com/get-started/

@georgefst
Copy link

The Dockerfile above worked for me for Spotifyd 0.3.4. I added && cd spotifyd && git checkout v0.3.4 to the penultimate RUN command to pin the version, and --features dbus_mpris to the final RUN command to get play/pause working. Unfortunately, I can't work out how to adapt this for 0.3.5. I bump the tag in the above argument to git checkout, one of the Rust dependencies complains about needing a newer rustc, so I try modifying 1.62.1 to 1.64.0, then weirdly end up with 404 errors from apt.

So I've taken a totally different path for now. Since I already had Nix installed on my RPi, I just ran ln -s $(nix --extra-experimental-features flakes --extra-experimental-features nix-command build nixpkgs#spotifyd --print-out-paths --no-link)/bin/spotifyd. This currently produces 0.3.4, but should pick up 0.3.5 once NixOS/nixpkgs#227382 is merged (the latest stable Nixpkgs set, which can be used by replacing nixpkgs#spotifyd with nixpkgs/22.11#spotifyd, ships 0.3.3).

@waldeckmatheus
Copy link

Hi @georgefst

  1. Until last contact on Oct 10, 2022, may some packages had upgraded.
  2. I checked new compilation some minutes ago and found some errors like about rustc version.
  • error: package time v0.3.20 cannot be built because it requires rustc 1.63.0 or newer, while the currently active rustc version is 1.62.1
  1. It was upgraded locally from 1.62.1 to 1.63 and a new error was found:
  • error: package spotifyd v0.3.5 (/root/spotifyd) cannot be built because it requires rustc 1.64 or newer, while the currently active rustc version is 1.63.0
  1. So, i changed rustc to 1.64 version and it was compiling successfully.
  2. It was added your suggest of "--features dbus_mpris" at end of latest RUN command.
  3. I'm happy that you found a new path too, i will check package manager Nix and learn about it.
  4. New dockerfile compiling spotifyd v0.3.5 is shared below.
FROM debian:latest

#if you run it on host, make a backup to restore later.
RUN cat /dev/null > /etc/apt/sources.list

RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian-security bullseye-security main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye-updates main' >> /etc/apt/sources.list

RUN apt update

RUN apt install gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu git curl pkg-config -y
RUN apt purge rustc -y

RUN echo "(curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path)" > /install-rust.sh && \ 
    chmod 755 /install-rust.sh && \ 
    /install-rust.sh
    
#v0.3.3 and v0.3.4: rustc 1.62.1
#v0.3.5: rustc 1.64.0
RUN chmod a+x /root/.cargo/env && \
    /bin/sh -c /root/.cargo/env && \ 
    /root/.cargo/bin/rustup default 1.64.0

RUN /root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu

RUN echo '[target.aarch64-unknown-linux-gnu]' >> /root/.cargo/config
RUN echo 'linker="aarch64-linux-gnu-gcc"' >> /root/.cargo/config

RUN dpkg --add-architecture arm64
#RUN apt install crossbuild-essential-arm64 -y

RUN apt install libasound2-dev:arm64 libssl-dev:arm64 libpulse-dev:arm64 libdbus-1-dev:arm64 -y

RUN apt install libasound2-dev portaudio19-dev build-essential libpulse-dev libdbus-1-dev libssl-dev libudev-dev -y

RUN cd /root/ && git clone https://github.com/Spotifyd/spotifyd.git

RUN /bin/bash -c "source /root/.cargo/env \
    && cd /root/spotifyd/ \
    && PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu --release --features dbus_mpris"

@georgefst
Copy link

Unfortunately those are the same modifications I made, and I hit:

Err:28 http://deb.debian.org/debian bullseye/main amd64 krb5-locales all 1.18.3-6+deb11u2
  404  Not Found [IP: 199.232.58.132 80]
Fetched 24.7 MB in 9s (2902 kB/s)
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/glibc/libc6_2.31-13%2bdeb11u4_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/k/krb5/krb5-locales_1.18.3-6%2bdeb11u2_all.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/l/linux/linux-libc-dev_5.10.140-1_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/k/krb5/libkrb5support0_1.18.3-6%2bdeb11u2_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/k/krb5/libk5crypto3_1.18.3-6%2bdeb11u2_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/k/krb5/libkrb5-3_1.18.3-6%2bdeb11u2_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/k/krb5/libgssapi-krb5-2_1.18.3-6%2bdeb11u2_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/glibc/libc6-dev_2.31-13%2bdeb11u4_arm64.deb  404  Not Found [IP: 199.232.58.132 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt install libasound2-dev:arm64 libssl-dev:arm64 libpulse-dev:arm64 libdbus-1-dev:arm64 -y' returned a non-zero code: 100

I have no idea what's causing that.

This imperfect reproducibility is one of the major reasons I prefer Nix over Docker for this sort of thing.

@UliPrantz
Copy link

UliPrantz commented Sep 5, 2023

@waldeckmatheus used your latest docker build script and the compiled image resulted in the following error when executing on a Raspberry Pi Zero 2 W with the latest Raspberry PI OS Lite (64-bit):

Running ./spotifyd --no-daemon results in:

./spotifyd: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./spotifyd)
./spotifyd: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./spotifyd)
./spotifyd: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./spotifyd)

Running: sudo apt install libc6 results in:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libc6 is already the newest version (2.31-13+rpt2+rpi1+deb11u5).

Any idea how to fix this to use the libc6 version that is already shipped with the OS?

@UliPrantz
Copy link

Got it working by changing the Dockerfile like this:

FROM debian:latest -> FROM debian:bullseye since bullseye has the correct GLIBC which it's linking against

FROM debian:latest

#if you run it on host, make a backup to restore later.
RUN cat /dev/null > /etc/apt/sources.list

RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian-security bullseye-security main' >> /etc/apt/sources.list
RUN echo 'deb [arch=amd64,arm64] http://deb.debian.org/debian bullseye-updates main' >> /etc/apt/sources.list

RUN apt update

RUN apt install gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu git curl pkg-config -y
RUN apt purge rustc -y

RUN echo "(curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path)" > /install-rust.sh && \ 
    chmod 755 /install-rust.sh && \ 
    /install-rust.sh
    
#v0.3.3 and v0.3.4: rustc 1.62.1
#v0.3.5: rustc 1.64.0
RUN chmod a+x /root/.cargo/env && \
    /bin/sh -c /root/.cargo/env && \ 
    /root/.cargo/bin/rustup default 1.64.0

RUN /root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu

RUN echo '[target.aarch64-unknown-linux-gnu]' >> /root/.cargo/config
RUN echo 'linker="aarch64-linux-gnu-gcc"' >> /root/.cargo/config

RUN dpkg --add-architecture arm64
#RUN apt install crossbuild-essential-arm64 -y

RUN apt install libasound2-dev:arm64 libssl-dev:arm64 libpulse-dev:arm64 libdbus-1-dev:arm64 -y

RUN apt install libasound2-dev portaudio19-dev build-essential libpulse-dev libdbus-1-dev libssl-dev libudev-dev -y

RUN cd /root/ && git clone https://github.com/Spotifyd/spotifyd.git

RUN /bin/bash -c "source /root/.cargo/env \
    && cd /root/spotifyd/ \
    && PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu --release --features dbus_mpris"

@mietzen
Copy link
Contributor

mietzen commented Sep 26, 2024

Cross Build using docker on every platform and OS:

  1. Setup Docker custom builder
docker buildx create \
  --name container-builder \
  --driver docker-container \
  --use --bootstrap
  1. Use Docker Compose for the build
services:
  build-container:
    image: rust:1.79-bookworm
    platform: linux/arm64
    command: bash -c "
        apt-get update &&
        apt-get install -y \
          libasound2-dev \
          libssl-dev \
          pkg-config &&
        curl -sSL https://api.github.com/repos/Spotifyd/spotifyd/tarball/v0.3.5 | tar xz -C /spotifyd --strip-components=1 &&
        cargo build --release &&
        cp /spotifyd/target/release/spotifyd /build/"
    working_dir: /spotifyd
    volumes:
      - ./:/build

This will copy the build spotifyd binary in the current directory.

mietzen added a commit to mietzen/spotifyd that referenced this issue Sep 26, 2024
Add documentation for e.g. building arm64 as described in Spotifyd#1053
mietzen added a commit to mietzen/spotifyd that referenced this issue Oct 17, 2024
Add documentation for e.g. building arm64 as described in Spotifyd#1053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants