gpt4 book ai didi

cmake - Rust中的Dockerfile错误,x86_64-unknown-linux-musl

转载 作者:行者123 更新时间:2023-12-03 11:47:22 24 4
gpt4 key购买 nike

我将按照此处显示的示例为Rust包创建一个Dockerfile:https://alexbrand.dev/post/how-to-package-rust-applications-into-minimal-docker-containers/

FROM rust:1.47.0 AS build
WORKDIR /usr/src

RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update
RUN apt-get install cmake musl-tools clang libc++-dev build-essential autoconf libtool pkg-config

# Create a dummy project and build the app's dependencies.
# If the Cargo.toml or Cargo.lock files have not changed,
# we can use the docker build cache and skip these (typically slow) steps.
RUN USER=root cargo new mypackage
WORKDIR /usr/src/mypackage
COPY Cargo.toml build.rs ./
COPY .git ./.git
RUN cargo build --release

# Copy the source and build the application.
COPY src ./src
RUN cargo install --target x86_64-unknown-linux-musl --path .
但是,它在安装 cargo 的步骤中失败了,这似乎是因为找不到 musl-g++。好像很奇怪
我误会了错误吗?我对如何继续前进迷失了方向。
这是完整的消息:
Step 12/16 : RUN cargo install --target x86_64-unknown-linux-musl --path .
---> Running in d861b7efa994
...
error: failed to run custom build command for `libmimalloc-sys v0.1.18`

Caused by:
process didn't exit successfully: `/usr/src/mypackage/target/release/build/libmimalloc-sys-9ec3b6c9ac1c8d9d/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/libmimalloc-sys-0.1.18/c_src/mimalloc" "-DMI_OVERRIDE=OFF" "-DMI_BUILD_TESTS=OFF" "-DMI_SECURE=OFF" "-DMI_LOCAL_DYNAMIC_TLS=OFF" "-Dmi_defines=MI_DEBUG=0" "-DCMAKE_INSTALL_PREFIX=/usr/src/mypackage/target/x86_64-unknown-linux-musl/release/build/libmimalloc-sys-ea7ff527a98597ef/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/musl-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=musl-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/musl-gcc" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/musl-gcc
-- Check for working C compiler: /usr/bin/musl-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring incomplete, errors occurred!
See also "/usr/src/mypackage/target/x86_64-unknown-linux-musl/release/build/libmimalloc-sys-ea7ff527a98597ef/out/build/CMakeFiles/CMakeOutput.log".
See also "/usr/src/mypackage/target/x86_64-unknown-linux-musl/release/build/libmimalloc-sys-ea7ff527a98597ef/out/build/CMakeFiles/CMakeError.log".

--- stderr
CMake Error at CMakeLists.txt:2 (project):
The CMAKE_CXX_COMPILER:

musl-g++

is not a full path and was not found in the PATH.

Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.


thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `mypackage v0.1.0 (/usr/src/mypackage)`, intermediate artifacts can be found at `/usr/src/mypackage/target`

Caused by:
build failed

最佳答案

我将从仅交互式运行基本镜像开始,然后寻找musl-g++。如果未找到,则将安装添加到Dockerfile中,然后重试。

关于cmake - Rust中的Dockerfile错误,x86_64-unknown-linux-musl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64887032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com