Created
July 19, 2025 23:06
-
-
Save JeffIrwin/5e8cdf102cca86dc38d420e6f0e4bf42 to your computer and use it in GitHub Desktop.
Build a minimal boost example linking to a subset of boost libs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Both rocky versions work | |
| #FROM rockylinux:8 | |
| FROM rockylinux:9 | |
| # This file builds a subset of boost from source and then builds and runs a | |
| # small example program which links to boost | |
| # | |
| # Reference: https://www.boost.org/doc/user-guide/getting-started.html | |
| #============================================== | |
| WORKDIR /workdir | |
| RUN \ | |
| dnf update -y && \ | |
| dnf install -y \ | |
| bzip2-devel \ | |
| gcc-c++ \ | |
| git \ | |
| libicu-devel \ | |
| python3 \ | |
| which \ | |
| zlib-devel | |
| RUN git clone \ | |
| #--branch master \ | |
| --depth 1 \ | |
| --branch boost-1.88.0 \ | |
| https://github.com/boostorg/boost | |
| ##============================================== | |
| WORKDIR /workdir/boost | |
| ## Build all boost modules | |
| #RUN git submodule update --init --recursive | |
| # Build only specific modules, e.g. lambda | |
| RUN git submodule update --depth 1 -q --init tools/boostdep | |
| RUN git submodule update --depth 1 -q --init libs/lambda | |
| RUN python3 tools/boostdep/depinst/depinst.py -X test -g "--depth 1" lambda | |
| RUN mkdir /usr/local/boost | |
| RUN ./bootstrap.sh | |
| RUN ./b2 | |
| RUN ./b2 install --prefix=/usr/local/boost | |
| ENV BOOST_ROOT=/usr/local/boost | |
| ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH | |
| ENV CPLUS_INCLUDE_PATH=/usr/local/boost/include:$CPLUS_INCLUDE_PATH | |
| #============================================== | |
| WORKDIR /workdir/ | |
| RUN cat <<EOF > ./example.cpp | |
| // Include a header from the Boost.Lambda library | |
| #include <boost/lambda/lambda.hpp> | |
| #include <iostream> | |
| #include <algorithm> | |
| int main() | |
| { | |
| using namespace boost::lambda; | |
| typedef std::istream_iterator<int> in; | |
| std::cout << "Enter numbers: "; | |
| // Read a sequence of integers from standard input, use Boost.Lambda to multiply each number by three, then write it to the standard output | |
| std::for_each( | |
| in(std::cin), in(), std::cout << (_1 * 3) << " "); | |
| } | |
| EOF | |
| RUN g++ -I /usr/local/boost/include example.cpp -o example | |
| RUN echo "10 11 12" | ./example | |
| # The whole boost installation is only 229 MB (185 MB of include headers and 45 | |
| # MB of libs) | |
| WORKDIR /usr/local/boost | |
| RUN du -h --max=1 | |
| WORKDIR /workdir/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment