skip to Main Content

I’m trying to build my CMake project on GitHub Actions workflow. Everything is working locally on Ubuntu 22.04 LTS and building a Docker image, but not when using the same OS on GitHub Actions.

The error is the following:

CMake Error at /usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR system filesystem thread
  date_time chrono regex serialization program_options)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.23/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
  CMakeLists.txt:261 (find_package)

My GitHub Actions workflow job:

install:
    name: Install Dependencies
    runs-on: ubuntu-22.04
    needs: [ clean ]
    steps:
      - uses: actions/checkout@v2

      - name: Install General
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential libboost-all-dev libssl-dev libffi-dev python3-dev gcc-11 g++-11 git cmake librocksdb-dev cron rpcbind libboost-system1.74.0 libboost-filesystem1.74.0 libboost-thread1.74.0 libboost-date-time1.74.0 libboost-chrono1.74.0 libboost-regex1.74.0 libboost-serialization1.74.0 libboost-program-options1.74.0 libicu70

  build:
    name: Build Target
    runs-on: ubuntu-22.04
    needs: [ install ]
    steps:
      - uses: actions/checkout@v2

      - name: Create Build Dir
        run: mkdir build
      - name: CMake
        run: cmake -DCMAKE_CXX_FLAGS="-g0 -Os -fPIC -std=gnu++17" -DBoost_DEBUG=ON -DBoost_ARCHITECTURE=-x64 ..
        working-directory: build
      - name: Make
        run: make -j$(nproc) --ignore-errors
        working-directory: build

My CMake configuration of Boost:

set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
message(STATUS "Boost Found: ${Boost_INCLUDE_DIRS}")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

When building it in a Docker container with Ubuntu 22.04 LTS it works without any problems.

My Dockerfile:

FROM ubuntu:22.04

COPY . /usr/src/project_name
WORKDIR /usr/src/project_name

# install build dependencies
RUN apt-get update && 
    apt-get install -y 
      build-essential 
      libssl-dev 
      libffi-dev 
      python3-dev 
      gcc-11 
      g++-11 
      git 
      cmake 
      librocksdb-dev 
      libboost-all-dev 
      libboost-system1.74.0 
      libboost-filesystem1.74.0 
      libboost-thread1.74.0 
      libboost-date-time1.74.0 
      libboost-chrono1.74.0 
      libboost-regex1.74.0 
      libboost-serialization1.74.0 
      libboost-program-options1.74.0 
      libicu70

# create the build directory
RUN mkdir build
WORKDIR /usr/src/project_name/build

# build and install
RUN cmake -DCMAKE_CXX_FLAGS="-g0 -Os -fPIC -std=gnu++17" .. && make -j$(nproc) --ignore-errors

WORKDIR /usr/src/project_name/build/src

All of the dependencies are installed on the GitHub runner with a job before. Any ideas why this might occur? Anyone else had this issue? I can post the CMake debug info if requested.

2

Answers


  1. Not an answer but a fragment to try. My Github action runner for ubuntu-latest looks as follows (you probably want to replace the install target in CMake build command with all.

    jobs:
      ubuntu-build:
        name: Ubuntu Build
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - name: Checkout submodules
            run: git submodule update --init --recursive
          - name: Create build directory and run CMake
            run: |
              sudo apt-get -y update
              sudo apt-get -y install libboost-dev
              cmake -S . -B cmake_build_dir -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake_install_dir
          - name: Build project
            run: cmake --build cmake_build_dir --target install --config Release -- -j4
          - name: Run tests
            run:  ctest -C Release -VV
            working-directory: cmake_build_dir
          - name: Create Artifacts
            uses: actions/upload-artifact@v1
            with:
              name: Ubuntu-Artifacts
              path: cmake_install_dir/
            if: always()
    
    Login or Signup to reply.
  2. github.com will give you a fresh runner for every job.

    See here https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#using-a-github-hosted-runner for details.

    Thus it is not possible to prepare the machine in one job and use it in a later job.

    You should move the installation of the needed packages inside your build job.

    In case you need to exchange artifacts, like binaries from one job to a later job, you should take a look at the github actions upload-artifact and download-artifact.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search