Closed AlexGisi closed 2 months ago
No (immediate) action required, but I came across an issue when compiling on macos 13.6 and wanted to record the fix.
The default clang version 14.0 has not implemented some of the c++20 features used. Hence, install the latest llvm version:
brew update brew install llvm
and add to .bashrc:
export PATH="/usr/local/opt/llvm/bin:$PATH" export LDFLAGS="-L/usr/local/opt/llvm/lib" export CPPFLAGS="-I/usr/local/opt/llvm/include" export CMAKE_PREFIX_PATH="/usr/local/opt/llvm"
Then change the standard library used by editing the CMakeLists.txt:
diff --git a/CMakeLists.txt b/CMakeLists.txt index 49e3aa6..5724a2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ option(BUILD_X86_64_BMI2 "Build with x86-64 bmi2 optimization" OFF) option(BUILD_DEBUG "Build with debug information" OFF) option(BUILD_NATIVE "Build with native optimizations" ON) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") + # Set the build type if(BUILD_DEBUG) set(CMAKE_BUILD_TYPE Debug) @@ -30,9 +33,9 @@ endif() set(CMAKE_CXX_FLAGS_RELEASE "-pthread -fopenmp -O3 -fomit-frame-pointer -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-pthread -fopenmp -O0 -DNDEBUG") -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") -endif() +# if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") +# endif() # Conditionally add static linking flag on Windows if(WIN32)
and compile with the newly installed version of clang instead:
mkdir build cd build cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
Hope this helps someone!
Thank you! I'll include this in the readme
No (immediate) action required, but I came across an issue when compiling on macos 13.6 and wanted to record the fix.
The default clang version 14.0 has not implemented some of the c++20 features used. Hence, install the latest llvm version:
and add to .bashrc:
Then change the standard library used by editing the CMakeLists.txt:
and compile with the newly installed version of clang instead:
Hope this helps someone!