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. QT posix message queue
Forum Update on Tuesday, May 27th 2025

QT posix message queue

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 3 Posters 11.2k Views 1 Watching
  • 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.
  • J jsulm
    19 May 2017, 06:40

    @jish Do you have this header file in your system?
    And can you show how you include it in your code?

    J Offline
    J Offline
    jish
    wrote on 19 May 2017, 06:46 last edited by
    #10

    @jsulm #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <Mqueue.h>
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    mqd_t mqid;
    mqid=mq_open("/hmi_chnl_ic",O_RDONLY);
    if(mqid==-1)
    {
    QDebug()<<"error opening message queue";
    }
    }
    this is the sample code..please forgive me if i'm asking anything stupid.And please do tell me where do ineed to add mqueue.h to get that in my program.

    J 1 Reply Last reply 19 May 2017, 06:47
    0
    • J jish
      19 May 2017, 06:46

      @jsulm #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <Mqueue.h>
      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      mqd_t mqid;
      mqid=mq_open("/hmi_chnl_ic",O_RDONLY);
      if(mqid==-1)
      {
      QDebug()<<"error opening message queue";
      }
      }
      this is the sample code..please forgive me if i'm asking anything stupid.And please do tell me where do ineed to add mqueue.h to get that in my program.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 19 May 2017, 06:47 last edited by
      #11

      @jish said in QT posix message queue:

      #include <Mqueue.h>

      it must be

      #include <mqueue.h>
      

      You need to include it where you want to use it. Where it is depends on your design.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 19 May 2017, 06:53
      0
      • J jsulm
        19 May 2017, 06:47

        @jish said in QT posix message queue:

        #include <Mqueue.h>

        it must be

        #include <mqueue.h>
        

        You need to include it where you want to use it. Where it is depends on your design.

        J Offline
        J Offline
        jish
        wrote on 19 May 2017, 06:53 last edited by jish
        #12

        @jsulm mqueue.h is also not working..
        You need to include it where you want to use it??? i tried to include it with the headers in .pro file..but no use.

        J 1 Reply Last reply 19 May 2017, 06:59
        0
        • J jish
          19 May 2017, 06:53

          @jsulm mqueue.h is also not working..
          You need to include it where you want to use it??? i tried to include it with the headers in .pro file..but no use.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 19 May 2017, 06:59 last edited by
          #13

          @jish "mqueue.h is also not working" - if you say something is not working you should always say what exactly is not working...
          I already asked you two times whether you have this header file in your system. Can you please answer this question?

          "You need to include it where you want to use it???" - before you asked "And please do tell me where do ineed to add mqueue.h to get that in my program". Maybe I misunderstood your question. You do not need to add this header file to your project. You just use it - system headers files are never added to the project directly.
          "i tried to include it with the headers in .pro file..but no use" - this is not needed! mqueue.h is usually already installed in your system (I guess you're using Linux?).
          This simple program should compile:

          #include "mqueue.h"
          
          int main(void)
          {
              return 0;
          }
          

          Does it compile if you do it like this:

          g++ -o test_mqueue test_mqueue.cpp
          

          ?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply 19 May 2017, 07:04
          1
          • J jsulm
            19 May 2017, 06:59

            @jish "mqueue.h is also not working" - if you say something is not working you should always say what exactly is not working...
            I already asked you two times whether you have this header file in your system. Can you please answer this question?

            "You need to include it where you want to use it???" - before you asked "And please do tell me where do ineed to add mqueue.h to get that in my program". Maybe I misunderstood your question. You do not need to add this header file to your project. You just use it - system headers files are never added to the project directly.
            "i tried to include it with the headers in .pro file..but no use" - this is not needed! mqueue.h is usually already installed in your system (I guess you're using Linux?).
            This simple program should compile:

            #include "mqueue.h"
            
            int main(void)
            {
                return 0;
            }
            

            Does it compile if you do it like this:

            g++ -o test_mqueue test_mqueue.cpp
            

            ?

            J Offline
            J Offline
            jish
            wrote on 19 May 2017, 07:04 last edited by jish
            #14

            @jsulm no idont have this header file in my system.That is why i'm asking where do add this header.

            M J 2 Replies Last reply 19 May 2017, 07:06
            0
            • J jish
              19 May 2017, 07:04

              @jsulm no idont have this header file in my system.That is why i'm asking where do add this header.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 19 May 2017, 07:06 last edited by
              #15

              @jish
              Its a linux header. Not related to Qt at all. This is where it is on my system

              alt text

              1 Reply Last reply
              0
              • J jish
                19 May 2017, 07:04

                @jsulm no idont have this header file in my system.That is why i'm asking where do add this header.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 19 May 2017, 07:06 last edited by
                #16

                @jish Do you use a Linux distribution?
                If so then install needed package. On Ubuntu you need to install libc6-dev package.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                J 1 Reply Last reply 19 May 2017, 07:11
                2
                • J jsulm
                  19 May 2017, 07:06

                  @jish Do you use a Linux distribution?
                  If so then install needed package. On Ubuntu you need to install libc6-dev package.

                  J Offline
                  J Offline
                  jish
                  wrote on 19 May 2017, 07:11 last edited by jish
                  #17

                  @jsulm i'm using linux distribution.
                  i am able to use mqueue.h in my linux program without any error. Only using with qt showed the error message.

                  J 1 Reply Last reply 19 May 2017, 07:12
                  0
                  • J jish
                    19 May 2017, 07:11

                    @jsulm i'm using linux distribution.
                    i am able to use mqueue.h in my linux program without any error. Only using with qt showed the error message.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 19 May 2017, 07:12 last edited by
                    #18

                    @jish It would be helpful to know which one.
                    What does

                    find /usr -name mqueue.h
                    

                    output?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    J 1 Reply Last reply 19 May 2017, 07:16
                    0
                    • J jsulm
                      19 May 2017, 07:12

                      @jish It would be helpful to know which one.
                      What does

                      find /usr -name mqueue.h
                      

                      output?

                      J Offline
                      J Offline
                      jish
                      wrote on 19 May 2017, 07:16 last edited by
                      #19

                      @jsulm said in QT posix message queue:

                      find /usr -name mqueue.h

                      output
                      /usr/include/mqueue.h
                      /usr/include/x86_64-linux-gnu/bits/mqueue.h
                      /usr/include/linux/mqueue.h
                      /usr/src/linux-headers-3.13.0-24-generic/include/config/posix/mqueue.h
                      /usr/src/linux-headers-3.13.0-117/include/uapi/linux/mqueue.h
                      /usr/src/linux-headers-3.13.0-117-generic/include/config/posix/mqueue.h
                      /usr/src/linux-headers-3.13.0-24/include/uapi/linux/mqueue.h

                      J 2 Replies Last reply 19 May 2017, 07:19
                      0
                      • J jish
                        19 May 2017, 07:16

                        @jsulm said in QT posix message queue:

                        find /usr -name mqueue.h

                        output
                        /usr/include/mqueue.h
                        /usr/include/x86_64-linux-gnu/bits/mqueue.h
                        /usr/include/linux/mqueue.h
                        /usr/src/linux-headers-3.13.0-24-generic/include/config/posix/mqueue.h
                        /usr/src/linux-headers-3.13.0-117/include/uapi/linux/mqueue.h
                        /usr/src/linux-headers-3.13.0-117-generic/include/config/posix/mqueue.h
                        /usr/src/linux-headers-3.13.0-24/include/uapi/linux/mqueue.h

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 19 May 2017, 07:19 last edited by
                        #20

                        @jish What is the error message after changing

                        #include <Mqueue.h>
                        

                        to

                        #include <mqueue.h>
                        

                        ?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        J 1 Reply Last reply 19 May 2017, 07:24
                        0
                        • J jish
                          19 May 2017, 07:16

                          @jsulm said in QT posix message queue:

                          find /usr -name mqueue.h

                          output
                          /usr/include/mqueue.h
                          /usr/include/x86_64-linux-gnu/bits/mqueue.h
                          /usr/include/linux/mqueue.h
                          /usr/src/linux-headers-3.13.0-24-generic/include/config/posix/mqueue.h
                          /usr/src/linux-headers-3.13.0-117/include/uapi/linux/mqueue.h
                          /usr/src/linux-headers-3.13.0-117-generic/include/config/posix/mqueue.h
                          /usr/src/linux-headers-3.13.0-24/include/uapi/linux/mqueue.h

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 19 May 2017, 07:20 last edited by
                          #21

                          @jish Can you upload your project to somewhere? I then can try to build it on my machine.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • J jsulm
                            19 May 2017, 07:19

                            @jish What is the error message after changing

                            #include <Mqueue.h>
                            

                            to

                            #include <mqueue.h>
                            

                            ?

                            J Offline
                            J Offline
                            jish
                            wrote on 19 May 2017, 07:24 last edited by
                            #22

                            @jsulm same..no such file or directory.
                            And i can't upload the the project since i'm working with a company.
                            Can you please try open a message queue using mq_open in qt creator?

                            J 1 Reply Last reply 19 May 2017, 07:30
                            0
                            • J jish
                              19 May 2017, 07:24

                              @jsulm same..no such file or directory.
                              And i can't upload the the project since i'm working with a company.
                              Can you please try open a message queue using mq_open in qt creator?

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 19 May 2017, 07:30 last edited by jsulm
                              #23

                              @jish This builds on my machine in QtCreator:

                              #include "mainwindow.h"
                              #include "ui_mainwindow.h"
                              
                              #include <QDebug>
                              
                              #include <mqueue.h>
                              
                              MainWindow::MainWindow(QWidget *parent) :
                                  QMainWindow(parent),
                                  ui(new Ui::MainWindow)
                              {
                                  ui->setupUi(this);
                              
                                  mqd_t mqid;
                                  mqid=mq_open("/hmi_chnl_ic",O_RDONLY);
                                  if(mqid==-1)
                                  {
                                      qDebug()<<"error opening message queue";
                                  }
                              }
                              
                              MainWindow::~MainWindow()
                              {
                                  delete ui;
                              }
                              

                              pro file:

                              #-------------------------------------------------
                              #
                              # Project created by QtCreator 2017-05-19T09:26:01
                              #
                              #-------------------------------------------------
                              
                              QT       += core gui
                              
                              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                              
                              TARGET = test_mqueue
                              TEMPLATE = app
                              
                              DEFINES += QT_DEPRECATED_WARNINGS
                              
                              LIBS += -lrt
                              
                              SOURCES += main.cpp\
                                      mainwindow.cpp
                              
                              HEADERS  += mainwindow.h
                              
                              FORMS    += mainwindow.ui
                              
                              

                              You need to add -lrt to be able to link.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply 19 May 2017, 07:50
                              3
                              • J jsulm
                                19 May 2017, 07:30

                                @jish This builds on my machine in QtCreator:

                                #include "mainwindow.h"
                                #include "ui_mainwindow.h"
                                
                                #include <QDebug>
                                
                                #include <mqueue.h>
                                
                                MainWindow::MainWindow(QWidget *parent) :
                                    QMainWindow(parent),
                                    ui(new Ui::MainWindow)
                                {
                                    ui->setupUi(this);
                                
                                    mqd_t mqid;
                                    mqid=mq_open("/hmi_chnl_ic",O_RDONLY);
                                    if(mqid==-1)
                                    {
                                        qDebug()<<"error opening message queue";
                                    }
                                }
                                
                                MainWindow::~MainWindow()
                                {
                                    delete ui;
                                }
                                

                                pro file:

                                #-------------------------------------------------
                                #
                                # Project created by QtCreator 2017-05-19T09:26:01
                                #
                                #-------------------------------------------------
                                
                                QT       += core gui
                                
                                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                                
                                TARGET = test_mqueue
                                TEMPLATE = app
                                
                                DEFINES += QT_DEPRECATED_WARNINGS
                                
                                LIBS += -lrt
                                
                                SOURCES += main.cpp\
                                        mainwindow.cpp
                                
                                HEADERS  += mainwindow.h
                                
                                FORMS    += mainwindow.ui
                                
                                

                                You need to add -lrt to be able to link.

                                J Offline
                                J Offline
                                jish
                                wrote on 19 May 2017, 07:50 last edited by jish
                                #24

                                @jsulm omg that solved my issue. Thank you very much.
                                one question where you saved mqueue.h in your system?

                                1 Reply Last reply
                                0

                                19/24

                                19 May 2017, 07:16

                                • Login

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