I created a simple Qt app to compile a C++ file using QProcess. Now when I try to run the exe file from the app using QProcess, it doesn't run. When I tried to open the file manually, I got an error saying "libwinpthread-1.dll is missing".
Here's how I compiled the file-
QFileInfo finfo(fileName);
exeFileName = QFileInfo( QDir(finfo.path()), finfo.baseName() + ".exe").filePath();
QStringList arguments;
arguments << fileName << "-o" << exeFileName;
process->start(QString("g++"), arguments);
And, this is the code for running it -
QProcess *runProcess = new QProcess(this);
runProcess->setStandardInputFile(inputFilename);
runProcess->setStandardOutputFile(QFileInfo(exeFileName).path() + "/output.txt");
connect(runProcess, SIGNAL(finished(int)), this, SLOT(runComplete(int)));
runProcess->start(exeFileName);
Basically, I want to compile and run a C++ file, provide it sample input file and store the standard output in a new file. What is wrong with this code? Or any other way of doing it? I am working on windows 7. Also, I cannot understand why does the compiled program need that dll file when compiled from the Qt app and runs fine when compiled manually.
Just in case, this is the file I am trying to compile
//file.cpp
#include <iostream>
int main() {
std::string s;
std::cin >> s;
std::cout << s;
return 0;
}