PDA

View Full Version : use process to start an external makefile



knobby67
31st July 2014, 11:59
Hi All,
I'm using Qt to call various makefiles on my Linux Ubuntu system just to automate some projects. From my reading I think I need to use process start but for some reason I can't get it to work. I know my paths ect are correct because I can use system to get make to work on a program. So in a folder I have a number of makes, SimMakefile, ArmMakefile, Linuxmakefile. Which I normally get to compile via terminal using for example "make -f SimMakefile"
So in Qt I tried


/*lets compile a game*/
directory.setCurrent( "/home/tony/Dropbox/Development/Projects/Games/TankBattle" );
/*just to test*/
QDir output;
QString newpath = output.currentPath( );
game_path = "make -f SimMakefile" ;
process.start( game_path );


however if I replace process start and setcurrent with linux system calls it works.



system("cd /home/tony/Dropbox/Development/Projects/Games/TankBattle");
system("make -f SimMakefile");


I've tried make as /usr/bin/make with no luck.

Can anyone advise how I should do this in Qt rather than use system calls.
Thanks

Lesiok
31st July 2014, 12:05
Change line 2 to :
process.setWorkingDirectoryt( "/home/tony/Dropbox/Development/Projects/Games/TankBattle" );

anda_skoa
31st July 2014, 12:37
And I would suggest to pass the program and its arguments separately



process.start("make", QStringList() << "-f" << "Makefile");


Cheers,
_

knobby67
31st July 2014, 14:50
Thankyou both got it. Getting to grips with Qt is a bit tricky the API is huge!