So I'm trying to create a new C++17 cmake project in QtCreator 4.8.1 and I've run into a small hiccup. It seems I'm using the correct linker and compiler but there must be a setting I'm missing somewhere as the (small) project I've done won't build.
g++-9 was not in Ubuntu so the first thing I did was install it (and gcc-9 too). Then I created a new kit and changed the C/C++ compiler to that one. I did not other changes to it.
#include <iostream>
#include <vector>
#include <algorithm>
#include <execution>
using namespace std;
int main()
{
std::cout << __cplusplus << std::endl;
std::vector<int> vec ={3, 2, 1, 4, 5, 6, 10, 8, 9, 4};
std::sort(vec.begin(), vec.end()); // sequential as ever
std::sort(std::execution::seq, vec.begin(), vec.end()); // sequential
std::sort(std::execution::par, vec.begin(), vec.end()); // parallel
std::sort(std::execution::par_unseq, vec.begin(), vec.end()); // parallel and vectorized
return 0;
}
Alas although I can follow the header into the correct more recent version the build system still complains std::execution::seq does not exist (and __cplusplus seems to keep pointing to the 2014 one)
edit: I've tried following suggestions in similar questions by adding set(CMAKE_CXX_STANDARD 17) to my cmake file but now I'm getting
In file included from /usr/include/c++/9/pstl/parallel_backend.h:14,
from /usr/include/c++/9/pstl/algorithm_impl.h:25,
from /usr/include/c++/9/pstl/glue_execution_defs.h:52,
from /usr/include/c++/9/execution:32,
from /home/pedro/LockLessDt/main.cpp:4:
/usr/include/c++/9/pstl/parallel_backend_tbb.h:19:10: fatal error: tbb/blocked_range.h: No such file or directory
| ^~~~~~~~~~~~~~~~~~~~~
Which sounds like a problem with the execution header.
__cplusplus now points to the correct value though.
This is my cmake file
cmake_minimum_required(VERSION 2.8)
project(LockLessDt)
set(CMAKE_CXX_STANDARD 17)
add_executable(${PROJECT_NAME} "main.cpp")