Page 1 of 1

Using run.sh from another program (Qt)

Posted: Tue Mar 24, 2015 3:07 pm
by grafzahl
Hi,

I want to use the run.sh 'IP' command from a GUI.
I work with Qt and made a button, which will start a subprocess:

Code: Select all

void MainWindow::CompileAndTransfer()
{
    QProcess *compAndtrans;
    compAndtrans = new QProcess(this);
    compAndtrans->setWorkingDirectory("/home/username/RedPitaya/SDK/");
    compAndtrans->start("./run.sh 'IP'");
    compAndtrans->waitForFinished();
    QString strOut = compAndtrans->readAllStandardOutput();
    qDebug() << strOut;
}
Output is:

Code: Select all

"make: Entering directory `/home/molsyst/RedPitaya/SDK/src'
rm -f api_test *.o ~* 
make: Leaving directory `/home/molsyst/RedPitaya/SDK/src'
make: Entering directory `/home/molsyst/RedPitaya/SDK/src'
arm-linux-gnueabi-gcc -c -g -std=gnu99 -Wall -Werror -I ../include/ trig-aqui.c -o trig-aqui.o
make: Leaving directory `/home/molsyst/RedPitaya/SDK/src'
" 
But neither "trig-aqui.o" nor "api_test" is in the dir, as it is usually after running the run.sh script from the shell.

Does anybody have an idea?

Tanks in advance
Graf Zahl

Re: Using run.sh from another program (Qt)

Posted: Tue Mar 24, 2015 9:23 pm
by Nils Roos
Hi,

My first guess would be that the compilation failed, eg. because the arm-linux-gnueabi-gcc compiler is not on any path that the Qt environment knows about.
I am not familiar with Qt specifics, but it looks like you capture only the standard output. To see error messages in the output, add "2>&1" to the command.

Code: Select all

compAndtrans->start("./run.sh 'IP' 2>&1");
Maybe things become clearer then.

Re: Using run.sh from another program (Qt)

Posted: Wed Mar 25, 2015 2:42 pm
by grafzahl
You are right:

Code: Select all

QProcess *compile1;
compile1 = new QProcess(this);
compile1->start(arm-linux-gnueabi-gcc);
qDebug() << compile1->errorString(); 

Code: Select all

"No such file or directory"
But why does Qt not know a program, which the terminal knows?

Re: Using run.sh from another program (Qt)

Posted: Thu Mar 26, 2015 10:09 am
by grafzahl
I had to use the full path of all programs, in this case:
Makefile:
CROSS_COMPILE = ../gcc_linaro/bin/arm-linux-gnueabi-

Now it works fine 8-)