How to install Boost on GitHub actions

How to install Boost for a C++ project on GitHub actions?

2 Likes

If you’re referring to the Linux virtual environment, you can use the apt package manager, you just have to specify the package names.

For example, here’s how I do to install webkit:

    - name: Install WebKit # required for SWT Browser
      run: |
        sudo apt update
        sudo apt install -y libwebkit2gtk-4.0-37

Thanks! I am referring to the Linux and the Windows virtual environment. But being able to get it working for Linux would already be great. So I installed Boost with

- name: Install Boost
      run: |
        sudo apt update
        sudo apt install -y libboost-all-dev

and the install seemed to work fine. But them when I try to use it CMake says it cannot find Boost. How do I set environment variables (like BOOST_ROOT, for example) so that CMake can find Boost?

Sorry I wouldn’t know… I haven’t been using Boost and C++ for ages. I seem to remember such a problem also when using autotools: the installation of boost in Ubuntu couldn’t be found automatically, and if I remember correctly Boost was installed in a non-standard location… you could try to reproduce the problem on your machine… in general, when running cmake on GitHub Actions you should be able to pass any command-line option or environment variable…

The best way is to use a multi platform package manager, such as vcpkg or conan.
If you’d like to try vcpkg, you can either use vcpkg directly on the workflow, or leverage the run-vcpkg action with automatic caching (which I authored).

If you need to compile Boost, I recommend @lukka’s approach above. However if you’re looking to just use a header-only library form Boost, compiling will be pretty painful - even if you cache it between builds: Github’s cache tends to auto-flush relatively frequently, and Boost takes a long while to compile on the standard runner.

For the header-only approach, you can just download, unpack boost, and set BOOST_ROOT so it can be found.

Here’s an example: Mudlet/build-mudlet.yml at 2887b5e847ed9e455940886e975e26468339db12 · Mudlet/Mudlet · GitHub (part 1) and Mudlet/build-mudlet.yml at 2887b5e847ed9e455940886e975e26468339db12 · Mudlet/Mudlet · GitHub (part 2).