Skip to content

General notes on compiler support

Jason Rice edited this page Dec 20, 2021 · 18 revisions

Hana demands a fairly high compliance of the C++ compiler and standard C++ library to the C++14 standard. Not all platforms support that natively, yet. On platforms providing full C++14 support, working with Hana is easy. On other platforms, you might have to jump through some hoops to get it working.

In general, the recommended compiler on any platform is Clang in its most recent stable version. However, compiler developers and package maintainers are currently making fast progress on C++14 standard compliance, for example Microsoft's MSVC compiler. So, check your system package manager for updates.

The following table gives an overview on confirmed successful builds of Hana. If your system doesn't provide these versions, refer to the notes below.

Compiler / Standard library Linux MacOS Windows Cygwin MSYS2 / MinGW64 Notes
GCC / any 6.0.0 6.0.0 - - - see comment below
Clang / libc++ 3.5.0 3.5.0 - - - clang -stdlib=libc++
Clang / libstdc++ 3.5.0 / 5.1.0 - - - 3.7.0 / 5.2.0 clang -stdlib=libstdc++
MSVC / MSVC's std lib - - VS2017 Update 7 or later - - see comment below
Intel C++ - - - - - see comment below

Comment on native Intel C++ compiler: Currently, it lacks at least support of C++14 variable templates N3651, one of the fundamental C++14 features Hana builds upon. Due to the prolonged update cycles, short term support for this compiler is rather unlikely.

When building Hana fails on your system, you may have encountered a problem which you haven't been aware of, yet. The C++ standard specifies compiler requirements and a Standard C++ Library. Both have to meet the C++14 standard to enable Hana's full functionality. Although compilers typically ship with a specific Standard C++ Library, your system may use a different setup by default. In particular, when using Clang, there are at least two possibilities of standard library: Clang's own libc++ and GNU's libstdc++. On OS X, the default since Mavericks is to use libc++. On Linux, however, the default is typically to use the libstdc++ provided with the native installation of GCC. On Windows, Clang could use the standard library provided with MSVC.

On all systems, building the examples and running the tests will require CMake.

Linux

Recently updated distributions should natively provide a working setup of Clang. Linux enterprise solutions might rely on some older versions due to the ensured long-term support. Check your system with clang++ -v, and, if necessary, try to find a repository for your distribution which provides versions as given in the table above.

With Clang you may choose which Standard C++ Library you want to link against using the compiler flag -stdlib=libc++ for Clang's own or -stdlib=libstdc++ for the one provided by GCC. When this flag is not given, you typically are implicitly choosing libstdc++.

OS X

To be done

Windows

On Windows, the Microsoft's native compiler, MSVC, has met the required standard conformance starting with their VS2017 Update 7 release. With that, there are now several options available:

  1. Install MSVC compiler from Visual Studio 2017 Update 7 or later

    As mentioned in these VCBlogs https://blogs.msdn.microsoft.com/vcblog/2018/06/04/use-boost-hana-via-vcpkg-with-the-latest-msvc-compiler/ and https://blogs.msdn.microsoft.com/vcblog/2018/05/07/announcing-msvc-conforms-to-the-c-standard/ , starting with Update 7 release of VS2017 MSVC is conformant to C++ standards and there is Boost.Hana branch that will work with the compiler. Official Boost.Hana branch will work with final VS2017 Update release.

  2. Install Clang with Visual Studio integration

    This is a special pre-built binary, intended as a drop-in replacement for MSVC with integration into Visual Studio. This compiler will use the standard library normally provided with MSVC. This is confirmed to build Hana successfully. See http://llvm.org/releases/download.html for stable releases and http://llvm.org/builds for snapshot releases and the Visual Studio 2015 integration.

  3. Install MinGW64 and the packages for Clang

    They are confirmed to work. See http://sourceforge.net/projects/mingw-w64 for an installer of one of many distributions.

  4. Install Cygwin64 along with the packages for Clang

    Unfortunately, there is only limited support since the Clang-provided libc++ is not compilable, yet. See https://www.cygwin.com for the installer.

If you are an experienced Visual Studio programmer, then option 1 would be recommended. Users more inclined to Linux environments should choose MinGW64.

With Cygwin or MinGW64, the above comments for Linux regarding Clang and the choice of a standard library apply.

A particular problem of Clang on Windows using Cygwin and MinGW is C++ exception handling. Since both compilers are originally developed for Linux, they are ported to the Windows platform and try to integrate into Windows exception handling. If you encounter linker errors containing missing symbols like __gxx_personality_v0 or __gxx_personality_seh0, try to compile without exceptions using the compiler flag -fno-exceptions. A similar problem may arise due to thread support being enabled in the GCC library. In that case, try adding -pthread to enable linking with POSIX thread support.

Other systems (Android, iOS, ...)

There are no reports yet about builds of Hana on other systems. However, for Android and iOS you might want to take a look at MSVC using their /permissive- mode, which is intended to provide cross-platform support for those systems.

Please give it a try and report success or failure by raising an issue at http://github.com/boostorg/hana.