Cross-Compiling to RISC-V with system dependencies (ALSA), how to do it?

Hi,

I'm new to cross-compilation but I recently got a small RISC-V single-board computer (running Armbian) and wanted to run some things on it.

Now, compiling to a different target in itself isn't much of a problem, but the problem is that the program I made uses CPAL, and transitively ALSA, so I obviously can't just link it against my system's alsa library.

This is the point where my current knowledge fails me, so I wonder if anyone can give me some pointers on where to look.

Compiling on the board itself sees awfully slow and thus not feasible.

Best,
N

You can use cross.

First make a Dockerfile similar to this, but with your RISC-V compilation target:

FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:latest

RUN dpkg --add-architecture riscv64 && \
    apt-get update && \
    apt-get install libasound2-dev:riscv64 -y && \

then set Cross.toml to what is below, with some minor changes.

[target.aarch64-unknown-linux-gnu]
dockerfile = "./path/to/where/the/Dockerfile/resides"

Hmm ok I got it to the point where it starts building, but with the latest docker image, there's no libasound2-dev package available. When I try the edge version of the image, I get the following error:

Compiling alsa-sys v0.3.1
Compiling jack-sys v0.2.3
error: failed to run custom build command for `jack-sys v0.2.3`

Caused by:
  process didn't exit successfully: `/target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build` (exit status: 1)
  --- stderr
  /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build)
  /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build)
  /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /target/debug/build/jack-sys-a2b75848e45c87b9/build-script-build)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `alsa-sys v0.3.1`

Caused by:
  process didn't exit successfully: `/target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build` (exit status: 1)
  --- stderr
  /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build)
  /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build)
  /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /target/debug/build/alsa-sys-6c1516645761a3a0/build-script-build)

Not sure what to do here, is there a more recent docker image I need to use, or install other packages ?

Ok, using this dockerfile:

FROM ghcr.io/cross-rs/riscv64gc-unknown-linux-gnu:edge

RUN dpkg --add-architecture riscv64 && apt update && apt upgrade -y && apt install libasound2-dev:riscv64 libjack-dev:riscv64 -y

and cargo clean before building seems to have fixed it, now it works ...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.