I'm writing a Multithreading program based on C++ 11 using "JetBrains CLion 2017.1". The code is here:
#include <stdlib.h>
#include <iostream>
#include <thread>
void thread_task() {
std::cout << "hello thread" << std::endl;
}
int main(int argc, const char *argv[])
{
std::thread t(thread_task);
t.join();
return EXIT_SUCCESS;
}
And the "CMakeLists.txt" is default:
cmake_minimum_required(VERSION 3.7)
project(AgileDev)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(AgileDev ${SOURCE_FILES})
But CLion cannot resolve "thread":
Error picture

I wondered where I was wrong. (T^T)
I had the exact same error. Apparently if you are using mingw it doesn't support standard threads. You should download this: https://github.com/meganz/mingw-std-threads
and add mingw.mutex.h and mingw.thread.h to your project directory.Include this at the top of your cpp source file.
#include "mingw.thread.h"
It should work then
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With