Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Release .exe doesn't start and does not give any errors
Forum Updated to NodeBB v4.3 + New Features

Release .exe doesn't start and does not give any errors

Scheduled Pinned Locked Moved Solved Installation and Deployment
14 Posts 3 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Strange... Do you have any early exit code path that could finish the program before it shows any GUI ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    A 1 Reply Last reply
    0
    • SGaistS SGaist

      Strange... Do you have any early exit code path that could finish the program before it shows any GUI ?

      A Offline
      A Offline
      Adham
      wrote on last edited by
      #5

      @SGaist said in Release .exe doesn't start and does not give any errors:

      Do you have any early exit code path that could finish the program before it shows any GUI ?

      No, main.cpp simply starts mainwindow.cpp and the user needs to make a selection on the MainWindow before anything happens

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        Then let's go with the basics.

        Can you remove everything from your code and just show an empty QWidget ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 2 Replies Last reply
        0
        • SGaistS SGaist

          Then let's go with the basics.

          Can you remove everything from your code and just show an empty QWidget ?

          A Offline
          A Offline
          Adham
          wrote on last edited by
          #7

          @SGaist said in Release .exe doesn't start and does not give any errors:

          Can you remove everything from your code and just show an empty QWidget ?

          Okay, if I understood you correctly I stripped everything from the mainwindow files (.cpp, .h and .ui) and just left it as an empty widget. (All the other files are still included in the .pro file however) and I still have the same issue

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adham
            wrote on last edited by
            #8

            So, I tried deploying from scratch, I

            1. copied the release .exe to an empty folder "release",
            2. I ran the following command, from the respective compiler directory, windeployqt.exe path_to_directory\release
            3. a bunch of .dlls were created, tried running, got a few errors about missing .dlls
            4. added the missing .dll files
            5. tried running again, I got the same result... no errors and the application doesn't start up
            6. copied the previous release .exe version to the same "release" directory and tried running it, runs fine

            I have no clue what I'm missing here

            1 Reply Last reply
            0
            • SGaistS SGaist

              Then let's go with the basics.

              Can you remove everything from your code and just show an empty QWidget ?

              A Offline
              A Offline
              Adham
              wrote on last edited by
              #9

              @SGaist said in Release .exe doesn't start and does not give any errors:

              Can you remove everything from your code and just show an empty QWidget ?

              I just removed all the files from the .pro file except the mainwindow files and main.cpp, and the now the app runs when placed in the deployment folder..

              It seems the problem is in one of the files, however I have over 200 files and there are many dependecies, so I am not sure how to go about debugging this

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Adham
                wrote on last edited by
                #10

                Okay so after a tedious debugging session, I found the file with the problem. I have a file globals.h that defines a bunch of global variables, objects & functions using the extern keyword. In globals.cpp I instantiate the variables and objects and implement the functions, initializing some of the variables to set default values. This file is included in almost every file in the project, and it seems that it is where the problem lies.

                This file was recently added to the project in the most recent version and was not included in previous ones. This file is crucial to the project, I am not sure why its causing this problem,

                the header file looks something like this:

                #ifndef GLOBALS_H
                #define GLOBALS_H
                
                #include <QDateTime>
                #include "serialport.h"
                #include "thread_one.h"
                ...
                
                extern int debug;
                extern QString name;
                
                //* Global Objects *//
                extern SerialPort serial;
                extern thread_one* threadOne;
                ...
                
                //* Global Variables *//
                extern int rate;
                extern int initialRate;
                extern double total;
                extern QByteArray data; //data recieved in port
                ...
                
                //* Global Functions *//
                extern QString date(); //current date
                extern QString time(); //current time
                extern double distance(int secs, int speed);
                ...
                
                #endif // GLOBALS_H
                

                and the implementation file:

                #include "globals.h"
                
                int debug = 1;
                QString name;
                
                SerialPort serial;
                thread_one* threadOne = new thread_one;
                
                int rate = 10;
                int initialRate = 0;
                double total = 0;
                QByteArray data;
                
                QString date() { return  QDateTime::currentDateTime().date().toString("MM:dd:yyyy").replace(":", "/");}
                QString time() { return  QDateTime::currentDateTime().time().toString("hh:mm:ss"); }
                double distance(int secs, int speed) { return distanceTraveled = static_cast<double>(speed * secs/3600); }
                

                I would greatly appreciate some help

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Several things:

                  • Do not use extern, use a namespace. You can declare your variables and functions there and the define them in your cpp files.
                  • Global objects are usually a bad sign with only a few exceptions. Many abuse them to pass these objects around in an easy way rather that build a proper architecture on top of them.

                  In fact it seams that the handling of the serial port and its data is done entirely through global objects which is a bad idea.

                  Implementation wise:

                  @Adham said in Release .exe doesn't start and does not give any errors:

                  QString date() { return QDateTime::currentDateTime().date().toString("MM:dd:yyyy").replace(":", "/");}

                  There's no need for that replace. Just use the slash directly in your format string.

                  Also, QDate directly provides currentDate so you are making more calls than actually necessary.

                  One last thing: date and time are not really good names for these functions. They in fact return a formatted string with the current date for the former and the current time for the later. This is not really maintenance friendly.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    Adham
                    wrote on last edited by Adham
                    #12

                    @SGaist
                    Thank you for your response.
                    I actually got assigned this project after it was developed for a couple of years and it was a disastrous mess, and my task was to maintain and upgrade it to follow a more proper object-oriented architecture. It's too big to simply rewrite from scratch and I'm learning more as I go.

                    Now, for using a namespace instead of extern statements, as I said earlier these are global variables, meaning they need to have the same value across all files, when I removed the extern statements and placed all the variables in a namespace called "globals" and used this namespace in all the other files using namespace globals; I got a ton of "multiple definition" errors.

                    I searched online and most, if not all, of the answers seem to point towards using the extern keyword to be able to achieve what I want. Using a namespace or not, it seems I would still need to declare the variables as extern to indicate that they may be included multiple times. Unless you mean to put all my code, across all files, inside the namespace, which doesn't seem like the right thing to do.

                    I still do no understand why my current implementation works fine when building and running in Qt but does not start when I deploy it.
                    So I am back to where I started..

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Adham
                      wrote on last edited by
                      #13

                      I solved the problem

                      T 1 Reply Last reply
                      0
                      • A Adham

                        I solved the problem

                        T Offline
                        T Offline
                        thinker9
                        wrote on last edited by
                        #14

                        @Adham How did you slove this problem, plz help, i have the same problem as you :(

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved