0

I am learning QT and c++. Managed to create a simple app to monitor the serial ports. Everything runs ok from INSIDE of Qt. BUT.... when i close Qt, goto debug folder and double click the .exe file, nothing happens. I want to share this app with my work colleagues - maybe just zip everything and send it to them so they can unzip to a folder and directly use the exe. Can't figure out how to do this basic thing. No tutorials exist that are suitable for newbie like me. I tried to install Inno Setup but not sure how to proceed from there.

EDIT: I copied comport.exe to release folder and I tried windeployqt.exe Comport.exe then get the results: (my app name is comport.exe).

G:\QT\build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug\release>C:\Qt\5.9.1\mingw53_32\bin\windeployqt.exe ComPort.exe
G:\QT\build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug\release\ComPort.exe 32 bit, debug executable
Adding Qt5Svg for qsvgicond.dll
Skipping plugin qtvirtualkeyboardplugind.dll due to disabled dependencies.
Direct dependencies: Qt5Core Qt5Gui Qt5SerialPort Qt5Widgets
All dependencies   : Qt5Core Qt5Gui Qt5SerialPort Qt5Widgets
To be deployed     : Qt5Core Qt5Gui Qt5SerialPort Qt5Svg Qt5Widgets
Warning: Cannot find GCC installation directory. g++.exe must be in the path.
Updating Qt5Cored.dll.
Updating Qt5Guid.dll.
Updating Qt5SerialPortd.dll.
Updating Qt5Svgd.dll.
Updating Qt5Widgetsd.dll.
Updating libGLESV2d.dll.
Updating libEGLd.dll.
Updating D3Dcompiler_47.dll.
Updating opengl32sw.dll.
Patching Qt5Cored.dll...
Creating directory G:/QT/build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug/release/iconengines.
Updating qsvgicond.dll.
Creating directory G:/QT/build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug/release/imageformats.
Updating qgifd.dll.
Updating qicnsd.dll.
Updating qicod.dll.
Updating qjpegd.dll.
Updating qsvgd.dll.
Updating qtgad.dll.
Updating qtiffd.dll.
Updating qwbmpd.dll.
Updating qwebpd.dll.
Creating directory G:/QT/build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug/release/platforms.
Updating qwindowsd.dll.
Creating G:\QT\build-ComPort-Desktop_Qt_5_9_1_MinGW_32bit-Debug\release\translations...
Creating qt_bg.qm...
Creating qt_ca.qm...
Creating qt_cs.qm...
Creating qt_da.qm...
Creating qt_de.qm...
Creating qt_en.qm...
Creating qt_es.qm...
Creating qt_fi.qm...
Creating qt_fr.qm...
Creating qt_gd.qm...
Creating qt_he.qm...
Creating qt_hu.qm...
Creating qt_it.qm...
Creating qt_ja.qm...
Creating qt_ko.qm...
Creating qt_lv.qm...
Creating qt_pl.qm...
Creating qt_ru.qm...
Creating qt_sk.qm...
Creating qt_uk.qm...

After this nothing happens. I open the release folder and found comport.exe with more files (dlls and folders). I doubleclick the exe still nothing happens.

EDIT: To the person who mark my question as "already has an answer" - my question is about Windows and not Unix/Linux and Mac.

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
GeneCode
  • 7,545
  • 8
  • 50
  • 85
  • read about windeployqt – eyllanesc Sep 15 '17 at 01:10
  • Yes i already tried that. it made some additional files in debug folder but still cant run it – GeneCode Sep 15 '17 at 01:15
  • Wait I will add more information in my question. – GeneCode Sep 15 '17 at 01:19
  • When running the .exe you need the appropriate dlls, if you are in debug mode you need named.dll for example QtCored.dll, but if you are in release mode you need the name.dll for example QtCore.dll, windeployqt copies those .dll and folders necessary to the folder where the executable is, if you have added third party libraries you are responsible for providing them. What do you expect in response, a tutorial? – eyllanesc Sep 15 '17 at 01:21
  • Do you have an error message when you double-click? – eyllanesc Sep 15 '17 at 01:24
  • No error when i double click. Just nothing. – GeneCode Sep 15 '17 at 01:24
  • Have you tried running it from cmd? – eyllanesc Sep 15 '17 at 01:25
  • running from cmd also shows nothing. – GeneCode Sep 15 '17 at 01:26
  • It confuses me a little your description, first you speak of the folder debug and later in what you show as a result the folder release is observed. – eyllanesc Sep 15 '17 at 01:27
  • Initially i supply windeployqt.exe with the exe in my debug folder. later, i copy this exe from debug folder to the release folder and run windeployqt with that one. Just trying stuffs since seems everything is not working. – GeneCode Sep 15 '17 at 01:28
  • 1
    Do not do that, the executable in debug mode is different from the release mode. You must change the compilation mode in Qt Creator and compile it in release mode. – eyllanesc Sep 15 '17 at 01:29
  • Ok i will try it. – GeneCode Sep 15 '17 at 01:30
  • 1
    @GeneCode Wrong, you should configure your project as Release, build and then use `windeployqt`. Also you may need to copy `libgcc_s_dw2-1.dll`, `libstdc++-6.dll` and `libwinpthread-1.dll` from `qtfolder/5.9/mingw.../bin `to your exe folder. – Macias Sep 15 '17 at 01:31
  • 1
    windeployqt assumes by default that you are providing release mode so you get those dlls, if you want to do the same for mode debug you should put: `windeployqt --debug your_executable` – eyllanesc Sep 15 '17 at 01:32
  • @Macias ok i will try that. – GeneCode Sep 15 '17 at 01:32
  • 1
    @Macias it works thank you. If you write answer then i can accept it. the manual copy of those libs is what i been missing. also eyllanesc, thank you for your comments. – GeneCode Sep 15 '17 at 01:35

1 Answers1

1

When you deploying your app using windeployqt default is release build, so if you want to deploy the debug version of libs (the ones with 'd' at the end) you have to pass --debug parameter.

You should never mix programs compiled as Release version with debug libs and Debug version with release libs. Debug libs have some extra code and they're not compatible with each other.

When you use MinGW, you may also need to copy libgcc_s_dw2-1.dll, libstdc++-6.dll and libwinpthread-1.dll from qtfolder/5.9/mingw.../bin to your exe folder.

Macias
  • 657
  • 4
  • 16