rust-cross / rust-musl-cross

Docker images for compiling static Rust binaries using musl-cross
MIT License
617 stars 68 forks source link

glib-2.0 and pkg-config issues (aarch64) #84

Closed aaronleopold closed 1 year ago

aaronleopold commented 1 year ago

Hello, I am trying to cross compile a dylib to aarch64 in a multi-staged docker image (the dylib gets used in a node app) but am encountering an error:

#0 28.01   error: could not find system library 'glib-2.0' required by the 'glib-sys' crate
#0 28.01
#0 28.01   --- stderr
#0 28.01   Package glib-2.0 was not found in the pkg-config search path.
#0 28.01   Perhaps you should add the directory containing `glib-2.0.pc'
#0 28.01   to the PKG_CONFIG_PATH environment variable
#0 28.01   No package 'glib-2.0' found
#0 28.01   Package glib-2.0 was not found in the pkg-config search path.
#0 28.01   Perhaps you should add the directory containing `glib-2.0.pc'
#0 28.01   to the PKG_CONFIG_PATH environment variable
#0 28.01   No package 'glib-2.0' found
#0 28.01
#0 28.01 warning: build failed, waiting for other jobs to finish...

I am attempting to install the packages pkg-config libgtk2.0-dev, but still the error occurs so have been stuck on this for a bit. Any help is appreciated, I'll paste some (hopefully) helpful snippets below:

FROM messense/rust-musl-cross:aarch64-musl AS arm64-arch

RUN apt-get update && apt-get install -y pkg-config libgtk2.0-dev

WORKDIR /app

COPY .cargo .cargo
COPY . .

ENV CARGO_NET_GIT_FETCH_WITH_CLI=true

RUN rustup target add aarch64-unknown-linux-musl && \
    cargo build --workspace --release --target aarch64-unknown-linux-musl && \
    mkdir libraries && find ./target/release -maxdepth 1 -type f -name "*.dylib" -exec cp {} libraries/ \;
[package]
name = "fs-utils"
version = "0.1.0"
edition = "2021"

[lib]
name = "fs_utils"
crate-type = ["dylib"]

[dependencies]
data-encoding = "2.3.2"
ring = "0.16.20"
safer-ffi = { version = "0.0.10", features = ["proc_macros"]}

# in my .cargo/config.toml
[target.aarch64-unknown-linux-musl]
rustflags = [
  "-C", "target-feature=-crt-static",
]
aaronleopold commented 1 year ago

sigh I forgot to exclude one of the packages in the workspace that caused all this