Skip to content

Instantly share code, notes, and snippets.

@sunapi386
Created March 8, 2019 03:32
Show Gist options
  • Select an option

  • Save sunapi386/f07c4b9abfc7d3f32e76679868d89dd5 to your computer and use it in GitHub Desktop.

Select an option

Save sunapi386/f07c4b9abfc7d3f32e76679868d89dd5 to your computer and use it in GitHub Desktop.
install g++-8 ubuntu 18.04 and configure cmake
cmake_minimum_required(VERSION 3.10)
project(project_name CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_REQUIRED_FLAGS -std=c++17)
include(CheckCXXSymbolExists)
add_executable(project_name project_name.cc)
set_property(TARGET project_name PROPERTY CXX_STANDARD 17)
## target_link_libraries(project_name) # link libraries here

The new C++17 language requires g++ >= 8.0. To install it in Ubuntu 18.04:

$ sudo apt install g++-8
...
$ which g++
/usr/bin/g++
$ which g++-8
/usr/bin/g++-8
$ sudo unlink g++
$ sudo link -s /usr/bin/g++-8 /usr/bin/g++
$ g++ --version
g++ (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment