I having trouble with this code, since the QApplication
line takes several seconds to return:
#include <QTime>
#include <QApplication>
#include <chrono>
#include <iostream>
int main(int argc, char **argv) {
auto t1 = std::chrono::high_resolution_clock::now();
QApplication app(argc, argv);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count() << " ms" << std::endl;
return 0;
}
With MinGW, the program returns 4702 ms
or something like that everytime (except a crazy 159983 ms
once!).
With Visual Studio, I waited 12 s
the first time, then 0.6 s
the other times, which is acceptable.
I am compiling with Ninja or CMake. What could be the reason of the QApplication
being so slow to be created and how to speed that up?
Thank you very much for your help.
EDIT: removing all the unnecessary dll in my directory (opencv_xxx.dll, etc.) solves the problem. But why? And how to avoid this?
My env: Windows 10, gcc 10.3.0, qt-5.15.1/mingw81_64
My compilation output with ninja:
cmd.exe /C "cd . && C:\msys64\mingw64\bin\c++.exe -O2 -g -DNDEBUG -Wl,-rpath,. programs/CMakeFiles/meyeEval.dir/meyeEval.cpp.obj -o bin\meyeEval.exe -Wl,--out-implib,lib\libmeyeEval.dll.a -Wl,--major-image-version,0,--minor-image-version,0 D:/Dev/dependances/T5/x64/qt-5.15.1/5.15.1/mingw81_64/lib/libQt5Qml.a D:/Dev/dependances/T5/x64/qt-5.15.1/5.15.1/mingw81_64/lib/libQt5Widgets.a D:/Dev/dependances/T5/x64/qt-5.15.1/5.15.1/mingw81_64/lib/libQt5Network.a D:/Dev/dependances/T5/x64/qt-5.15.1/5.15.1/mingw81_64/lib/libQt5Gui.a D:/Dev/dependances/T5/x64/qt-5.15.1/5.15.1/mingw81_64/lib/libQt5Core.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd .