Qprocess not taking proper arguments
-
hey i am trying to call a process from Qprocess but it's not taking args properly .
below is the code
#include <QCoreApplication> #include <QProcess> #include <QDebug> #include <QObject> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QObject *parent = nullptr; QProcess *process = new QProcess(parent); const QString program = "meson"; const QStringList args = {"introspect", "--targets", "/home/nightmare/practice/meson/builddir/"}; process->setProcessChannelMode(QProcess::ForwardedChannels); process->start(program, args); return a.exec(); } OUTPUT of above code :
usage: meson [-h] [--prefix PREFIX] [--libdir LIBDIR]
[--libexecdir LIBEXECDIR] [--bindir BINDIR] [--sbindir SBINDIR]
[--includedir INCLUDEDIR] [--datadir DATADIR] [--mandir MANDIR]
[--infodir INFODIR] [--localedir LOCALEDIR]
[--sysconfdir SYSCONFDIR] [--localstatedir LOCALSTATEDIR]
[--sharedstatedir SHAREDSTATEDIR]
[--backend {ninja,vs,vs2010,vs2015,vs2017,xcode}]
[--buildtype {plain,debug,debugoptimized,release,minsize}]
[--strip] [--unity {on,off,subprojects}] [--werror]
[--layout {mirror,flat}] [--default-library {shared,static}]
[--warnlevel {1,2,3}] [--stdsplit] [--errorlogs]
[--cross-file CROSS_FILE] [-D PROJECTOPTIONS] [-v]
[--wrap-mode {WrapMode.default,WrapMode.nofallback,WrapMode.nodownload}]
[directories [directories ...]]
meson: error: unrecognized arguments: --targets /home/nightmare/practice/meson/builddir/but when i try it from terminal same commands the output is right
meson introspect --targets /home/nightmare/practice/meson/builddir/ [{"build_by_default": true, "name": "myexe", "filename": "myexe", "id": "myexe@exe", "installed": false, "type": "executable"}]
-
@Qjay
Although one has to respect the output you show from typing at the terminal, from themeson
usage message I have to say I can see neitherintrospect
nor--targets
arguments, which seems pretty odd.... ?[If
introspect
is one of the directories, I still don't see the--targets
after that in the usage...]If you perhaps practised with some other command & arguments (e.g.
ls
), you might satisfy thatQProcess
does indeed pass arguments correctly.... -
this was the command i passed in terminal : "meson introspect --targets /home/nightmare/practice/meson/builddir/"
and this was the output : "[{"build_by_default": true, "name": "myexe", "filename": "myexe", "id": "myexe@exe", "installed": false, "type": "executable"}]"
-
Hi,
Do you have several versions of meson installed ?
Do you have maybe a modifiedPATH
environment variable in your command prompt ? -
-
terminal does the path expansion but qprocess does not
For the record, that is not true. Unless your shell has an "alias" for
meson
, which I doubt.More likely they have different
PATH
environment variables. Which does not explain why you say you received messagemeson: error: unrecognized arguments
, which would not happen ifmeson
(of some kind) was not on yourPATH
. You may like to investigate why that is, up to you. -
You might have modified
PATH
in your terminal session only for example.Or you may have modified
PATH
in the Run part of the Project panel.