最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

cmake - How to better built VCPKG packages in docker - Stack Overflow

programmeradmin5浏览0评论

I am trying to build these packages of vcpkg

RUN vcpkg install \
    boost \
    boost-hana \
    cereal \
    cpr \
    curl \
    ffmpeg[fdk-aac,mp3lame,vorbis,vpx,x264,x265] \
    geographiclib \
    gettext-libintl \
    google-cloud-cpp[datastore,functions,oauth2,storage] \
    grpc \
    icu \
    libphonenumber \
    nameof \
    opencv \
    protobuf \
    --triplet=x64-linux \
    --clean-after-build

But my system requirements never seem to be good enough as the built keeps failing for many different reasons. Here is my code for now the docker file

# syntax=docker/dockerfile:1.4

###############################################################################
# Stage 1: deps
#  - Installs all system dependencies needed for building
#  - Installs ccache, configures compilers, sets up vcpkg
#  - Installs heavy dependencies via vcpkg
###############################################################################
FROM --platform=linux/amd64 ubuntu:22.04 AS deps

# Prevent interactive prompts and set timezone
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# (1) Install system dependencies
RUN apt-get update && \
    apt-get install -y \
      build-essential \
      wget \
      git \
      ccache \
      ninja-build \
      python3 \
      python3-pip \
      python3-venv \
      python3-jinja2 \
      curl \
      zip \
      unzip \
      pkg-config \
      openssl \
      doxygen \
      autoconf \
      automake \
      autoconf-archive \
      libtool \
      m4 \
      nasm \
      bison \
      flex \
      libc-dev \
      libjsoncpp-dev \
      uuid-dev \
      lcov \
      libssl-dev \
      zlib1g-dev \
      gcc \
      g++ \
      libsystemd-dev \
    && rm -rf /var/lib/apt/lists/*

# (2) (Optional) Build a recent CMake from source
WORKDIR /tmp/cmake
RUN wget .27.1/cmake-3.27.1.tar.gz && \
    tar -xzf cmake-3.27.1.tar.gz && \
    cd cmake-3.27.1 && \
    ./bootstrap --prefix=/usr/local -- -DOPENSSL_ROOT_DIR=/usr && \
    make -j"$(getconf _NPROCESSORS_ONLN)" && make install && \
    cd / && rm -rf /tmp/cmake

ENV PATH="/usr/local/bin:${PATH}"

# (3) Install a specific Ninja version
RUN git clone .git /tmp/ninja \
    && cd /tmp/ninja \
    && git checkout v1.10.2 \
    && cmake -Bbuild-cmake -H. \
    && cmake --build build-cmake \
    && cp build-cmake/ninja /usr/local/bin/ninja \
    && rm -rf /tmp/ninja

# (4) Setup Python environment (if required)
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip jinja2

# (5) Clone and bootstrap vcpkg into /vcpkg
WORKDIR /vcpkg
RUN git clone .git /vcpkg && \
    cd /vcpkg && \
    git fetch --tags && \
    git checkout 2025.02.14 && \
    ./bootstrap-vcpkg.sh -disableMetrics && \
    ln -s /vcpkg/vcpkg /usr/local/bin/vcpkg

RUN vcpkg update
# (6) Set vcpkg environment
ENV VCPKG_ROOT="/vcpkg"
ENV VCPKG_DEFAULT_TRIPLET="x64-linux"
#ENV VCPKG_FORCE_SYSTEM_BINARIES=0
ENV VCPKG_MAX_CONCURRENCY=10
ENV VCPKG_MANIFEST_MODE=OFF
ENV PATH="/vcpkg:$PATH"

# (7) Pre-install heavy dependencies via vcpkg
RUN vcpkg install \
    boost \
    boost-hana \
    cereal \
    cpr \
    curl \
    ffmpeg[fdk-aac,mp3lame,vorbis,vpx,x264,x265] \
    geographiclib \
    gettext-libintl \
    google-cloud-cpp[datastore,functions,oauth2,storage] \
    grpc \
    icu \
    libphonenumber \
    nameof \
    opencv \
    protobuf \
    --triplet=x64-linux \
    --clean-after-build

last error was something like this

820.4 -- Extracting source /vcpkg/downloads/boost-filesystem-boost-1.86.0.tar.gz
1820.5 -- Using source at /vcpkg/buildtrees/boost-filesystem/src/ost-1.86.0-3caa6a5187.clean
1820.5 -- Configuring x64-linux
1824.7 CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
1824.7     Command failed: /vcpkg/downloads/tools/ninja/1.12.1-linux/ninja -v
1824.7     Working Directory: /vcpkg/buildtrees/boost-filesystem/x64-linux-rel/vcpkg-parallel-configure
1824.7     Error code: 1
1824.7     See logs for more information:
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-dbg-CMakeCache.txt.log
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-rel-CMakeCache.txt.log
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-dbg-CMakeConfigureLog.yaml.log
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-rel-CMakeConfigureLog.yaml.log
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-rel-ninja.log
1824.7       /vcpkg/buildtrees/boost-filesystem/config-x64-linux-out.log
1824.7 
1824.7 Call Stack (most recent call first):
1824.7   installed/x64-linux/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:269 (vcpkg_execute_required_process)
1824.7   installed/x64-linux/share/vcpkg-boost/boost-install.cmake:55 (vcpkg_cmake_configure)
1824.7   ports/boost-filesystem/portfile.cmake:12 (boost_configure_and_install)
1824.7   scripts/ports.cmake:196 (include)
1824.7 
1824.7 
1824.7 error: building boost-filesystem:x64-linux failed with: BUILD_FAILED

I need help here to understand what am missing or doing wrong.

发布评论

评论列表(0)

  1. 暂无评论