+ Reply to Thread
Results 1 to 9 of 9

Thread: "Process failed to start: " and qprocess generic errors

  1. #1
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default "Process failed to start: " and qprocess generic errors

    Afternoon --

    I can't seem to find a simple problem I'm having addressed anywhere in the forum or google, so I'm hoping someone can point me in the right direction...I'm sure it's something small...

    I am trying to call a simple cmd application that takes 2 parameters, an input file and output file with QProcess -- it looks like it should be a very easy thing to do but I'm getting errors that really don't help me much...if I use "proc->start(...)" the error I get is, "Process failed to start: ", and if I use proc->execute (...), I get "Unknown error"...It might be something in my pathnames, but I need another set of eyes at this point...

    From the command line, this is how I call the application and it works perfectly:
    C:\Users\Scott\Desktop\Star\Genriser\src\genriser test.input test.output

    mainwindow.h
    Qt Code:
    1. .
    2. .
    3. .
    4. private:
    5. Ui::MainWindow *ui;
    6. QProcess *genriser_proc;
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. QString genriser_dir;
    2. QStringList arguments;
    3.  
    4. genriser_proc = new QProcess;
    5.  
    6. genriser_dir = "C:\\Users\\Scott\\Desktop\\Star\\Genriser\\src";
    7. QDir::setCurrent(genriser_dir);
    8.  
    9. arguments << "test.input";
    10. arguments << "test.output";
    11.  
    12. genriser_proc->start(program, arguments);
    To copy to clipboard, switch view to plain text mode 

    I have tried not setting a working directory and putting the full pathname of the executable and the files in the string, I've tried the overloaded versions of QProcess::start and execute, but to no avail.


    Any ideas? I'm sure it'll be something embarrassing...

    scott

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 140 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: "Process failed to start: " and qprocess generic errors

    Have you tried:
    Qt Code:
    1. genriser_dir = "C:\\Users\\Scott\\Desktop\\Star\\Genriser\\src";
    2. //QDir::setCurrent(genriser_dir);
    3. genriser_proc->setWorkingDirectory(genriser_dir);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: "Process failed to start: " and qprocess generic errors

    That's actually what I tried first but was getting a can't find directory or file error, so searching found me this:

    http://www.qtforum.org/article/15350...y-problem.html

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    6,436
    Thanks
    13
    Thanked 1,359 Times in 1,301 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: "Process failed to start: " and qprocess generic errors

    Where is 'program' set and what is its value?

  5. #5
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: "Process failed to start: " and qprocess generic errors

    Oops, that would help to have shown the whole piece of code -- cut and paste issues...

    mainwindow.cpp
    Qt Code:
    1. QString input_file;
    2. QString output_file;
    3. QString program;
    4. QString genriser_dir;
    5. QStringList arguments;
    6.  
    7. input_file = "C:\\Users\\Scott\\Desktop\\Starmark\\Genriser\\src\\test.input";
    8. output_file = "C:\\Users\\Scott\\Desktop\\Starmark\\Genriser\\src\\test.output";
    9. program = "C:\\Users\\Scott\\Desktop\\Starmark\\Genriser\\src\\genriser";
    10. genriser_dir = "C:\\Users\\Scott\\Desktop\\Starmark\\Genriser\\src";
    11.  
    12. genriser_proc = new QProcess;
    13.  
    14. QDir::setCurrent(genriser_dir);
    15.  
    16. arguments << input_file;
    17. arguments << output_output;
    18.  
    19. genriser_proc->start(program, arguments);
    To copy to clipboard, switch view to plain text mode 

    If I fully qualify the pathnames in my variables, I get the "Process failed to start" error...However, if I remove the pathnames and just rely on the setCurrent command to define the directory, I get "Process crashed"...

    When I did a qDebug() on "arguments", it shows the string encased in parentheses, and I'm wondering if that's where my problem is originating because my command line needs to look like this, "...\src\genriser test.input test.output"...Does the QStringlist append parenthesis or is that something that's just appearing with the debug?

    I've also tried, "genriser_proc->start("genriser test.input test.output)" and that didn't work either...


    scott


    ed. calling my main application, which has no parameters, works -- so does run qtcreator if I point all my variables to it's directory, so that narrows it down to something to do with the arguments...
    Last edited by scott_hollen; 21st November 2011 at 18:05.

  6. #6
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: "Process failed to start: " and qprocess generic errors

    I'm about to throw my Mac against the wall...Every application I invoke with QProcess works except for the one I need to have work...I even modified the external app to not need parameters but it still bombs...Running that app from the cmd line works; double clicking on it in File Manager works...Calling it from my Qt app generates a "Process crashed" error and I'm at a loss as to how to debug that...I didn't want to have to fold this app into my Qt app, but I'm almost to the point of having to do that...

    scott

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    6,436
    Thanks
    13
    Thanked 1,359 Times in 1,301 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: "Process failed to start: " and qprocess generic errors

    If it is complaining that the process crashed then it must have found the file.

    Are you sure the genriser program runs on its own without crashing?
    Can you start a non-Qt command prompt (whatever it's called on a Mac), cd to the directory, and run the command yourself?
    Is the environment that your sub-process inherits correct? Can the program find all its dynamically loaded dependencies (Qt libs etc.)?

    When you say a "simple cmd application" do mean a simple executable or a shell script?

  8. #8
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: "Process failed to start: " and qprocess generic errors

    I'm running VMware on my Mac and it's running Vista...Also trying this on my Windows 7 machine with the same result...

    Yep, 100% sure that genriser (genriser.exe) is working -- it takes an input file, does a lot of hocus pocus on it, and creates an output file which is then fed to another application...I can run it from the dos command prompt and it creates my output file, and I can double click on it in Windows Explorer as well and it creates the file...

    The genriser app is a fairly large c++ application, compiles fine, executes fine...I've checked file perms, everything's fine...It resides in the exact same directory as my Qt application which is calling it (I've moved it all over the place thinking that might help but nooooooooo)...I can call other .exe apps with QProcess with no problem including my Qt application, qtcreator.exe itself and other Windows .exe's like calc and it works fine, so obviously I've narrowed it down to *something* with genriser, but I'm hitting a wall with the debugging of this; "process crashed" isn't exactly a detailed explanation...


    Added after 1 23 minutes:


    Well, when I run genriser thru QtCreator's external debugger, it works just fine so there must just be some working/running directory confusion going on when I kick it off from my Qt app...For testing reasons I've hardcoded genriser with files names without the path and since it works at the cmd prompt, Windows Explorer and now the debugger, that pretty much narrows it down to pathnames being off but how I don't know...Everything in my Qt app is hardcoded, I'm now setting a working directory and current directory to the same location as genriser, I've output the directory contents via Qt and still I'm crashing...

    Time for a beer...Thanks for the help!!!

    scott
    Last edited by scott_hollen; 22nd November 2011 at 03:23.

  9. #9
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: "Process failed to start: " and qprocess generic errors

    SOLVED!!!! There was a compiler incompatibility issue apparently...I had been compiling my genriser app at the cmd line, so I created a new project in QtCreator and imported all the code and builtit there...Now my Qt app can call the newly Qt-generated genriser executable via QProcess!

    Thanks for the help!


    scott
    Last edited by scott_hollen; 22nd November 2011 at 18:54.

+ Reply to Thread

Similar Threads

  1. Replies: 7
    Last Post: 8th November 2012, 11:26
  2. Qt Creator Qt SDK, Remote Compiler "Build Failed: Errors in build"
    By strahlex in forum Qt Tools
    Replies: 0
    Last Post: 10th August 2011, 16:59
  3. The Gdb process failed to start.
    By been_1990 in forum Qt Tools
    Replies: 3
    Last Post: 29th April 2009, 17:29
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. Replies: 2
    Last Post: 20th November 2007, 20:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts