Skip to content

Setting up a custom standard library

LChris314 edited this page Jul 3, 2018 · 2 revisions

When the default standard library shipped with your system is too old for Hana to use, you can either install a new standard library system-wide, or install it locally and tell Hana how to use it. To do so, you must specify

  1. A custom header search path. This instructs the compiler to look for headers in the /path/to/std-includes directory. This way, when you #include <type_traits>, for example, it will look for that header in the /path/to/std-includes directory.

    export CXXFLAGS="-I /path/to/std-includes"
  2. A custom library search path and library to link against. This instructs the linker to search for libraries in the /path/to/std-library directory, and to link against the std-library library, which should be present in the directory you provided.

    export LDFLAGS="-L /path/to/std-library -l std-library"
  3. A custom search path for loading shared libraries at runtime. This will be looked up by your program at startup time.

    export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/path/to/std-library"

For example, using a custom libc++ on my Linux box looks like:

export CXXFLAGS="-I ${HOME}/code/llvm36/build/include/c++/v1"
export LDFLAGS="-L ${HOME}/code/llvm36/build/lib -l c++ -l c++abi"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOME}/code/llvm36/build/lib"
cmake .. -DCMAKE_CXX_COMPILER=clang++-3.6
Clone this wiki locally