Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Exe doesn't run correctly when executed with QProcess::start
Qt 6.11 is out! See what's new in the release blog

Exe doesn't run correctly when executed with QProcess::start

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 2.4k Views 2 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.
  • I Offline
    I Offline
    incantation
    wrote on last edited by incantation
    #1

    I'm developing a gui for a third party software. It works fine when I run the .exe, but when I try to run it via QProcess it looks like it can't access a library. It's a program written in C and contained in a Visual Studio project, the .exe is contained in C:/Program Files (x86)/Gage/Compuscope/Compuscope C SDK/C Samples/Advanced/Gagestream2disk/x64/Debug/stream.exe. It's using libraries contained in C:/Program Files (x86)/Gage/Compuscope/include and it seems to be working fine with those, since the gui does display the name of the hardware, which uses proprietary drivers. But when calling functions defined in C:\Program Files (x86)\Gage\CompuScope\CompuScope C SDK\C Common it doesn't work. There is a system variable for C:\Program Files (x86)\Gage\CompuScope\ . So because of that I tried setting the environment with

    QProcessEnvironment env=QProcessEnvironment::systemEnvironment();
    env.insert("GageDir", "C:\\Program Files (x86)\\Gage\\Compuscope\\");
    

    This still didn't help. I've also tried to set the project build and run environment to use that path. And that didn't work either.

    I'm pretty sure this is Qt connected since the exe works perfectly fine when executed by itself, but so far I couldn't find a solution to this.
    Just for reference here is a snippet of the code for QProcess:

    QString program="C:\\Program Files (x86)\\Gage\\CompuScope\\CompuScope C SDK\\C Samples\\Advanced\\GageStream2Disk\\x64\\Debug\\GageStream2Disk.exe";
    QStringList arguments;
    QProcess *streamingProcess=new QProcess(this);
    streamingProcess->start(program, arguments);
    

    Any help would be appreciated!

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

      Hi and welcome to devnet,

      You can check what that application uses with Dependency Walker. This might give you a clue about what is happening.

      Did you also check the stdout and stderr content of your QProcess object ?

      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
      0
      • I Offline
        I Offline
        incantation
        wrote on last edited by
        #3

        Thanks for the quick reply, the only thing that is somehow connected to the software dependencies wise is C:\Windows\system32\CsAppSupport.dll .
        I merged stdout and stderr and the QProcess outputs fine, just not what it usually does when running the .exe.

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

          What does it output ?

          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
          0
          • I Offline
            I Offline
            incantation
            wrote on last edited by
            #5

            The outpus is as follows:

            Board Name: CSE161G4 (The boardname is acquired by one of the functions defined in the include folder)

            Cannot find Stream2Disk.ini - using default parameters. (The .ini file is searched by the configuration function inside CsAppSupport.h, the next 3 lines are connected to the .ini file)

            No ini entry for Stm configuration. Using defaults.
            Selecting Expert Stream from image 1.

            Failed to create the directory

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Hi, just guessing, but try removing that extra space before "...\ Gage", like this:

              env.insert("GageDir", "C:\\Program Files (x86)\\Gage\\Compuscope\\");
              
              1 Reply Last reply
              1
              • I Offline
                I Offline
                incantation
                wrote on last edited by
                #7

                Sorry about that, that was a mistake typing it out, there's no space in the code. I'll edit that now

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #8

                  Have you tried copying the Stream2Disk.ini file to the same directory as the program (GageStream2Disk.exe)?

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    incantation
                    wrote on last edited by
                    #9

                    It is there, there is no issue with the .ini file when executing the .exe not from the gui.

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by
                      #10

                      Ok. Maybe you need to do a cd (change directory) to where the .exe file and the .ini file are.

                      1 Reply Last reply
                      1
                      • I Offline
                        I Offline
                        incantation
                        wrote on last edited by
                        #11

                        Don't think that is a problem since the path is specified correctly in the program variable.

                        jsulmJ 1 Reply Last reply
                        0
                        • Kent-DorfmanK Offline
                          Kent-DorfmanK Offline
                          Kent-Dorfman
                          wrote on last edited by Kent-Dorfman
                          #12

                          Just for giggles, create a dos batch file with your command in it and try to execute the batch file as a QProcess. Try both explicitly using the path to the executable, and by inserting the chdir to where the exe lives.

                          Something is not being set right in your process environment. you may be able to work-around by making sure needed environment variables are set in a batch file.

                          Are all DLL search directories in the PATH? IIRC, windoze searches the PATH for DLLs.

                          The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

                          1 Reply Last reply
                          2
                          • I incantation

                            Don't think that is a problem since the path is specified correctly in the program variable.

                            jsulmJ Online
                            jsulmJ Online
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @incantation I would try to set working directory of the process to that where the ini file is located.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            3
                            • I Offline
                              I Offline
                              incantation
                              wrote on last edited by
                              #14

                              @Kent-Dorfman Thanks for the suggestion, but would this approach work if I need to read from and write to the process?
                              All the .dll dependencies are in C:\windows\system32 and I checked both the path variable and the environment of the process and it's present in both

                              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