Skip to content

Instantly share code, notes, and snippets.

@so298
Last active December 13, 2023 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save so298/7c6ef1f93873284bc59817ea44459907 to your computer and use it in GitHub Desktop.
Save so298/7c6ef1f93873284bc59817ea44459907 to your computer and use it in GitHub Desktop.
Build Boost-C++ library with Fujitsu compiler

Build Boost-C++ library with Fujitsu compiler (FCC/FCCpx)

FCCpx is a cross compiler for login node. So if you build boost on computation nodes, you should replace FCCpx command with FCC.

1. Get source code

VARIANT="1_83_0"; \
  wget "https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_${VARIANT}.tar.gz" && \
  tar xvf "boost_${VARIANT}.tar.gz" && \
  cd boost_${VARIANT};

2. Build boost

Please change INSTALL_PREFIX arbitrary. See B2 Documentation for more detail.

./bootstrap.sh
INSTALL_PREFIX="$(pwd)/.install"; \
  echo "using clang : fcc : FCCpx ;" > user-config.jam && \
  ./b2 --prefix="$INSTALL_PREFIX" --without-python pch=off --user-config=user-config.jam toolset=clang-fcc -j $(nproc) install

3. Use boost in your application

The code to check boost version (boost_version.cc)

#include <boost/version.hpp>
#include <iostream>

int main() {
    std::cout << "Boost version: " 
              << BOOST_VERSION / 100000 << "."       // major version
              << BOOST_VERSION / 100 % 1000 << "."   // minor version
              << BOOST_VERSION % 100                 // patch level
              << std::endl;
    return 0;
}

Compile and run

# Setup environment vars
export BOOST_ROOT="/path/to/boost/install"
export LD_LIBRARY_PATH="$BOOST_ROOT/lib:$LD_LIBRARY_PATH"

# Build your app
FCCpx boost_version.cc -o boost_version -I$BOOST_ROOT/include

# On computing node
./boost_version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment