I am a student who is new to Qt. I started coding this program with Qt Concurrent functionality. The program is supposed to calculate whether a number diverges or converges to 1. I am assuming that if the length exceeds 100, it diverges.
This is my code
#include <QtConcurrent/QtConcurrentMap>
#include <QFuture>
#include <vector>
#include <iostream>
using namespace std;
bool converges(int &n)
{
int count = 0;
while (count < 100 && n > 1)
{
if (n % 2 == 0)
{
n = n/2;
}
else
{
n = 3*n+1;
}
if(count > 100)
{
break;
}
count = count + 1;
}
if (n = 1 && count <= 100)
return true;
else
return false;
}
int main(int argc, char *argv[])
{
int N = 1000000;
vector <int> data;
for(int i = 0; i < N; i++)
{
data.push_back(i);
}
QFuture <void> res = QtConcurrent::map(data,converges);
res.waitForFinished();
return 0;
}
But I get build error. Any suggestions where I am going wrong?
This is the error I keep getting
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QtConcurrent::ThreadEngineBase::ThreadEngineBase(void)" (__imp_??0ThreadEngineBase@QtConcurrent@@QAE@XZ) referenced in function "public: __thiscall QtConcurrent::IterateKernel > >,void>::IterateKernel > >,void>(class std::_Vector_iterator > >,class std::_Vector_iterator > >)" (??0?$IterateKernel@V?$_Vector_iterator@V?$_Vector_val@U?$_Simple_types@H@std@@@std@@@std@@X@QtConcurrent@@QAE@V?$_Vector_iterator@V?$_Vector_val@U?$_Simple_types@H@std@@@std@@@std@@0@Z)