Created
July 19, 2025 02:04
-
-
Save JeffIrwin/291a9da81fe2ca4f3a74c5e2bf31186a to your computer and use it in GitHub Desktop.
Build boost from source on rocky linux 9 in docker
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
| FROM rockylinux:9 | |
| # This file builds boost "from source" (actually from a release tarball, not a | |
| # direct git clone) 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++ \ | |
| libicu-devel \ | |
| python3 \ | |
| which \ | |
| zlib-devel | |
| ADD https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.gz . | |
| RUN tar xvf boost_*.tar.gz | |
| RUN rm boost_*.tar.gz | |
| RUN mv boost_* boost | |
| #============================================== | |
| WORKDIR /workdir/boost | |
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment