Hello All.c
I have the latest mingw version (4.7.1) and i have it set-up and successfully ran a sample file (which i post below)in CodeBlocks using the mention compiler.
Now i want to use std::thread in Qt. when i try to compile this sample:
#include <QCoreApplication>
#include <iostream>
#include <vector>
#include <thread>
void func(int tid)
{
std::cout << "Launched by thread " << tid << std::endl;
}
int main(int argc, char *argv[])
{
std::vector<std::thread> th;
int nr_threads = 10;
for (int i = 0; i < nr_threads; ++i)
{
th.push_back(std::thread(func,i));
}
for(auto &item : th)
{
item.join();
}
return a.exec();
}
#include <QCoreApplication>
#include <iostream>
#include <vector>
#include <thread>
void func(int tid)
{
std::cout << "Launched by thread " << tid << std::endl;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::vector<std::thread> th;
int nr_threads = 10;
for (int i = 0; i < nr_threads; ++i)
{
th.push_back(std::thread(func,i));
}
for(auto &item : th)
{
item.join();
}
return a.exec();
}
To copy to clipboard, switch view to plain text mode
I get an error saying :
C:\Users\Master\Documents\Qt\ThreadCpp11\main.cpp: 4: error: C1083: Cannot open include file: 'thread': No such file or directory
.
What other steps are necessary in order to get this to work in QtCreator?(QT4.8.2)
here are some pics showing my settings :


Thanks in advance
Bookmarks