cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.72k stars 375 forks source link

how can i cross compile rust project from windows10 to linux #1532

Open sxfreesky123 opened 3 months ago

sxfreesky123 commented 3 months ago

Cross.toml:

[build] default-target = "x86_64-unknown-linux-gnu"

[target.x86_64-unknown-linux-gnu] pre-build = [ "apt-get update && apt-get install -y libssl-dev" ]

execute in windows cmd: cross run --target x86_64-unknown-linux-gnu

================== [cross] warning: using newer rustc 1.80.0 (051478957 2024-07-21) for the target. Current active rustc on the host is rustc 1.79.0 (129f3b996 2024-06-10).

Update with rustup update Dockerfile.x86_64-unknown-linux-gnu-custom:5

3 | ARG CROSS_DEB_ARCH= 4 | ARG CROSS_CMD 5 | >>> RUN eval "${CROSS_CMD}"

ERROR: failed to solve: process "/bin/sh -c eval \"${CROSS_CMD}\"" did not complete successfully: exit code: 100

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/2m9nekppq5j9aevvv3jww4c4k Error: 0: could not run container 1: when building custom image 2: when pre-building 3: "C:\Program Files\Docker\Docker\resources\bin\docker.exe" build --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=d:\works\raymond\bc_works' --tag cross-custom-bc_works:x86_64-unknown-linux-gnu-76b69-pre-build --build-arg 'CROSS_CMD=apt-get update && apt-get install -y libssl-dev' --build-arg 'CROSS_DEB_ARCH=amd64' --file 'd:\works\raymond\bc_works\target\x86_64-unknown-linux-gnu\Dockerfile.x86_64-unknown-linux-gnu-custom' 'd:\works\raymond\bc_works' failed with exit code: 100

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1: BaseThreadInitThunk at : 2: RtlUserThreadStart at :

Note: CROSS_CMD=apt-get update && apt-get install -y libssl-dev.

Before that, i've tried use CROSS_CMD in Cross.toml:

[target.x86_64-unknown-linux-gnu] pre-build = [ "dpkg --add-architecture $CROSS_DEB_ARCH", "apt-get update && apt-get --assume-yes install libssl-dev:$CROSS_DEB_ARCH" ]

but the same problem.

Emilgardis commented 3 months ago

ERROR: failed to solve: process "/bin/sh -c eval "${CROSS_CMD}"" did not complete successfully: exit code: 100

Suggests an error with your docker. What does docker-desktop://dashboard/build/desktop-linux/desktop-linux/2m9nekppq5j9aevvv3jww4c4k say? (Paste it into a webbrowser)

sxfreesky123 commented 3 months ago

ERROR: failed to solve: process "/bin/sh -c eval "${CROSS_CMD}"" did not complete successfully: exit code: 100

Suggests an error with your docker. What does docker-desktop://dashboard/build/desktop-linux/desktop-linux/2m9nekppq5j9aevvv3jww4c4k say? (Paste it into a webbrowser)

oh, yes, thank you for reminding me