From 1eac15304dd4427a7f46807360c557b180f8a6e5 Mon Sep 17 00:00:00 2001 From: djairoh Date: Fri, 19 Apr 2024 10:20:32 +0200 Subject: [PATCH] fix: forgot a line under compiling for linux --- opening-hdf5/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opening-hdf5/README.md b/opening-hdf5/README.md index 890a39d..ec2a268 100644 --- a/opening-hdf5/README.md +++ b/opening-hdf5/README.md @@ -20,16 +20,20 @@ make ``` ### Building with Linux -Makes use of `mdspan` which is not supported by GCC libstdc++ at time of writing. See [compiler support](https://en.cppreference.com/w/cpp/compiler_support/23) for `mdspan`. The solution to this is to use Clang and libc++; this is configured in our CMake setup, however the default installation of the `netcdf-cxx` package on at least Arch linux (and suspectedly Debian derivatves as well) specifically builds for the glibc implementation. To get the netcdf C++ bindings functional with the libc++ implementation, one needs to build from source. On Linux, this requires a few changes to the CMake file included with the netcdf-cxx source code, which are detailed below. +Makes use of `mdspan` which is not supported by glibc++ at time of writing. See [compiler support](https://en.cppreference.com/w/cpp/compiler_support/23) for `mdspan`. The solution to this is to use Clang and libc++; this is configured in our CMake setup, however the default installation of the `netcdf-cxx` package on at least Arch linux (and suspectedly Debian derivatives as well) specifically builds for the glibc implementation. To get the netcdf C++ bindings functional with the libc++ implementation, one needs to build from source. On Linux, this requires a few changes to the CMake file included with the netcdf-cxx source code, which are detailed below. Step-by-step to build the program using clang++ and libc++ on linux: 1. Download the source code of netcdf-cxx, found at 'https://github.com/Unidata/netcdf-cxx4/releases/tag/v4.3.1' (make sure to download the release source code, as the master branch contains non-compilable code). - 2. Build the source code with the following flags: + 2. Edit the CMakeLists.txt file, by appending '-stdlib=libc++' to the `CMAKE_CXX_FLAGS` variable in line 430. This means line 430 should read: + ```cmake + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wno-unused-variable -Wno-unused-parameter -stdlib=libc++") + ``` + 2. Build the source code with the following: ```sh mkdir build && cd build cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++ make ctest - make install + sudo make install ``` 3. Now the code should compile through the standard steps described in the Compiling section.