Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qprocess not taking proper arguments
QtWS25 Last Chance

Qprocess not taking proper arguments

Scheduled Pinned Locked Moved Solved General and Desktop
qprocessqt creatorqtcore
10 Posts 4 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qjay
    wrote on 22 May 2018, 14:16 last edited by Qjay
    #1

    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"}]

    J 1 Reply Last reply 22 May 2018, 14:23
    0
    • Q Qjay
      22 May 2018, 14:16

      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"}]

      J Offline
      J Offline
      JonB
      wrote on 22 May 2018, 14:23 last edited by JonB
      #2

      @Qjay
      Although one has to respect the output you show from typing at the terminal, from the meson usage message I have to say I can see neither introspect 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 that QProcess does indeed pass arguments correctly....

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qjay
        wrote on 22 May 2018, 15:10 last edited by
        #3

        introspect is not a directory . introspect is a a argument / parameter that meson takes ( mentioned in official docs of meson too )

        have you tried it on your meson project ??

        P 1 Reply Last reply 22 May 2018, 16:16
        0
        • Q Qjay
          22 May 2018, 15:10

          introspect is not a directory . introspect is a a argument / parameter that meson takes ( mentioned in official docs of meson too )

          have you tried it on your meson project ??

          P Offline
          P Offline
          Pablo J. Rogina
          wrote on 22 May 2018, 16:16 last edited by
          #4

          @Qjay just in case, the meson output you posted didn't include --targets and the QStringList args shown above didn't include the JSON parameter you shown in the command line example.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • Q Offline
            Q Offline
            Qjay
            wrote on 22 May 2018, 16:33 last edited by
            #5

            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"}]"

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 22 May 2018, 19:58 last edited by
              #6

              Hi,

              Do you have several versions of meson installed ?
              Do you have maybe a modified PATH environment variable in your command prompt ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • Q Offline
                Q Offline
                Qjay
                wrote on 23 May 2018, 05:29 last edited by
                #7

                found it . It was my fault . i was calling meson directly whereas meson is installed in "/usr/local/bin/meson"

                terminal does the path expansion but qprocess does not .

                so i changed it to const QString program = "/usr/local/bin/meson";

                works fine now :)

                J 1 Reply Last reply 23 May 2018, 07:22
                2
                • Q Qjay
                  23 May 2018, 05:29

                  found it . It was my fault . i was calling meson directly whereas meson is installed in "/usr/local/bin/meson"

                  terminal does the path expansion but qprocess does not .

                  so i changed it to const QString program = "/usr/local/bin/meson";

                  works fine now :)

                  J Offline
                  J Offline
                  JonB
                  wrote on 23 May 2018, 07:22 last edited by JonB
                  #8

                  @Qjay

                  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 message meson: error: unrecognized arguments, which would not happen if meson (of some kind) was not on your PATH. You may like to investigate why that is, up to you.

                  1 Reply Last reply
                  2
                  • Q Offline
                    Q Offline
                    Qjay
                    wrote on 23 May 2018, 07:55 last edited by
                    #9

                    hmm you are right too . Not sure why it happened though.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 23 May 2018, 08:00 last edited by
                      #10

                      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.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      10/10

                      23 May 2018, 08:00

                      • Login

                      • Login or register to search.
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved