QProcess execute a unkown program



  • Hi,

    i want to execute with QProcess a program (arm-linux-gnueabi-gcc), which Qt doesn't know. I need that for cross-compiling code for a Red Pitaya.

    Terminal:

    • molsyst@molsyst:~$ arm-linux-gnueabi-gcc
    • arm-linux-gnueabi-gcc: fatal error: no input files
    • compilation terminated.
      (program is recognised)

    Qt:

    • QProcess *compile1;
    • compile1 = new QProcess(this);
    • compile1->start("arm-linux-gnueabi-gcc");
    • qDebug() << compile1->errorString();
      Output:
    • Select all"No such file or directory"

    But why does Qt not know a program, which the terminal knows?

    I already asked this question in the RedPitaya Forum ( http://forum.redpitaya.com/viewtopic.php?f=14&t=465&p=1764 ), but i think here it is better placed.

    Thanks in advance
    GrafZahl



  • Hi,

    You have to provide the full path



  • Precisely. Here's a good example that can help.

    http://doc.qt.io/qt-5/qdir.html

    One other thing that can help, as a plan B.

    You can execute a normal Linux process under Qt using the system (" ") call from within Qt -with arguments included in " ", or try:

    Example:
    {
    const char* sys_command;

    sys_command.toLatin1().constData() ;
    system(sys_command);
    }



  • Thanks for answers.

    Full path was the solution, now it works fine. 8-)
    I also now use the system command.

    Thanks



  • @grafzahl said:

    I also now use the system command.

    If you can, I suggest to use QProcess to run external commands. This for two reasons:

    1. QProcess is cross-platform (in the future you could want to build your application also on other platforms);
    2. You can have direct access to the standard out/err, ....

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.