Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. segmentation fault
Forum Update on Tuesday, May 27th 2025

segmentation fault

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt 4.8cross-compilingarmv7mqtt
61 Posts 6 Posters 24.7k 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.
  • M Milav
    12 Oct 2019, 10:31

    Hello,

    I make a qt application for Embedded Custom Board and when i run the Application it gives segmentation fault.

    The application give segmentation fault due to following line.

      mosq->subscribe(mosq->getMID(), topic.data(), 1);
    

    where mosq is define and declare as follow.

    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        qtmosq* mosq = NULL;
        QStringList subed;
        QString currentTopic;
        Ui::MainWindow *ui;
    --------
    --------
    --------
    };
    

    where qtmosq is define as follow..

    #include "QObject"
    #include "mosquittopp.h"
    
    using namespace mosqpp;
    
    class qtmosq : public QObject, public mosquittopp
    {
        Q_OBJECT
    
    public:
        qtmosq(const char *id = NULL, bool clean_session = true) : mosquittopp (id, clean_session) {MID = 0;}
        ~qtmosq() {}
    
        void on_connect(int result)
        {
            if (!result)
            {
                //subscribe(NULL, "$SYS/#", 2);
                emit connected();
            }
            else
                emit connectEnable();
        }
        void on_publish(int id)
        {
            MID++;
            emit messageSent(true);
        }
        void on_subscribe(int mid, int qos_count, const int *granted_qos)
        {
            if (MID != 0)
                emit subscribed();
            MID++;
        }
    ..........
    ..........
    ..........
    
    signals:
        void connected();
        void messageSent(bool);
        void messageReceived(QString);
        void connectEnable();
        void subscribed();
    };
    

    so what is the reason behind for this fault.

    The same application are successfully run on Host Linux PC.

    I have use same mosquitto library in both the test.

    please help me to sort out this problem.

    I have send the reference link at where i used above program.

    Link :- Ref. Link

    Thank you
    Milav Soni

    P Offline
    P Offline
    Pablo J. Rogina
    wrote on 15 Oct 2019, 16:51 last edited by
    #48

    @Milav said in segmentation fault:

    Link :- Ref. Link

    Could it be possible that you run such example AS IS, I mean just download/clone the code and try such example without any change.
    If you manage to make it work, then you'll have the foundation to start adapting it to whatever you need/desire.

    In addition, is there any compelling reason not to use the Qt MQTT module?
    Have you try any of the Qt MQTT examples?

    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

    M 1 Reply Last reply 16 Oct 2019, 04:59
    0
    • P Pablo J. Rogina
      15 Oct 2019, 16:51

      @Milav said in segmentation fault:

      Link :- Ref. Link

      Could it be possible that you run such example AS IS, I mean just download/clone the code and try such example without any change.
      If you manage to make it work, then you'll have the foundation to start adapting it to whatever you need/desire.

      In addition, is there any compelling reason not to use the Qt MQTT module?
      Have you try any of the Qt MQTT examples?

      M Offline
      M Offline
      Milav
      wrote on 16 Oct 2019, 04:59 last edited by
      #49

      @Pablo-J-Rogina said in segmentation fault:

      In addition, is there any compelling reason not to use the Qt MQTT module?
      Have you try any of the Qt MQTT examples?

      I use actually qt4.8.7 source for development so QMqtt is not build for this qt version, so that i do not use qmqtt class.

      if you have any idea how to run QMqtt in qt 4.8.7 source than please tell me it is so helpful to me.

      @Pablo-J-Rogina said in segmentation fault:

      Could it be possible that you run such example AS IS, I mean just download/clone the code and try such example without any change.
      If you manage to make it work, then you'll have the foundation to start adapting it to whatever you need/desire.

      i actually tried same as is code for pc development and that is work fine.

      but when i cross compiling the code for embedded target board than it gives segmentation error,

      the difference between host pc and Embedded target board is only QT source.

      Host pc => qmake (qt version 5.4.0 )
      Embedded target => qmake (qt version 4.8.7)

      hope you got my point.

      if you have any query please tell me.

      and please guys help me to sort out the problem.

      i am also try another code for the same , but in that i have also suffer same problem.

      Another code link :- link text

      J P 2 Replies Last reply 16 Oct 2019, 05:16
      0
      • M Milav
        16 Oct 2019, 04:59

        @Pablo-J-Rogina said in segmentation fault:

        In addition, is there any compelling reason not to use the Qt MQTT module?
        Have you try any of the Qt MQTT examples?

        I use actually qt4.8.7 source for development so QMqtt is not build for this qt version, so that i do not use qmqtt class.

        if you have any idea how to run QMqtt in qt 4.8.7 source than please tell me it is so helpful to me.

        @Pablo-J-Rogina said in segmentation fault:

        Could it be possible that you run such example AS IS, I mean just download/clone the code and try such example without any change.
        If you manage to make it work, then you'll have the foundation to start adapting it to whatever you need/desire.

        i actually tried same as is code for pc development and that is work fine.

        but when i cross compiling the code for embedded target board than it gives segmentation error,

        the difference between host pc and Embedded target board is only QT source.

        Host pc => qmake (qt version 5.4.0 )
        Embedded target => qmake (qt version 4.8.7)

        hope you got my point.

        if you have any query please tell me.

        and please guys help me to sort out the problem.

        i am also try another code for the same , but in that i have also suffer same problem.

        Another code link :- link text

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 16 Oct 2019, 05:16 last edited by
        #50

        @Milav OK, maybe we should start from the beginning.
        Do you cross compile from PC to device?
        Does the app crash in same way on host with Qt5?
        Is it possible that you're mixing Qt4 and Qt5 on your target device? You can check this using "ldd EXECUTABLE" on your target.
        Please do this on your target (in a terminal):

        file /opt/milav/qt-mosquitto
        ldd /opt/milav/qt-mosquitto
        

        and post the output here.

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

        M 2 Replies Last reply 16 Oct 2019, 05:39
        0
        • J jsulm
          16 Oct 2019, 05:16

          @Milav OK, maybe we should start from the beginning.
          Do you cross compile from PC to device?
          Does the app crash in same way on host with Qt5?
          Is it possible that you're mixing Qt4 and Qt5 on your target device? You can check this using "ldd EXECUTABLE" on your target.
          Please do this on your target (in a terminal):

          file /opt/milav/qt-mosquitto
          ldd /opt/milav/qt-mosquitto
          

          and post the output here.

          M Offline
          M Offline
          Milav
          wrote on 16 Oct 2019, 05:39 last edited by
          #51

          @jsulm said in segmentation fault:

          OK, maybe we should start from the beginning.

          Okay sure.

          @jsulm said in segmentation fault:

          Do you cross compile from PC to device?

          Yes i cross compile the "qt-mosquitto" application for target (device) from qt creator (that is install on pc).

          For cross compilng i have use qmake version 4.8.7.

          and qt creator version is "Qt Creator 3.3.0 (opensource)"

          and for v

          @jsulm said in segmentation fault:

          Does the app crash in same way on host with Qt5?

          No, the application is not crash in PC.

          In pc i have use same code but qmake vwersion is 5.4.0

          @jsulm said in segmentation fault:

          Is it possible that you're mixing Qt4 and Qt5 on your target device? You can check this using "ldd EXECUTABLE" on your target.

          In target i have only qt 4 library and qmake are there.
          i think there is no qt 5 component in target device.

          @jsulm said in segmentation fault:

          Please do this on your target (in a terminal):

          sorry for this, but i have not ldd command on target device.
          if it is necessary than tell i have install and cross compile it for target device.

          sorry i dont know why this ldd cmd is not there in target device.

          J 1 Reply Last reply 16 Oct 2019, 05:42
          0
          • M Milav
            16 Oct 2019, 05:39

            @jsulm said in segmentation fault:

            OK, maybe we should start from the beginning.

            Okay sure.

            @jsulm said in segmentation fault:

            Do you cross compile from PC to device?

            Yes i cross compile the "qt-mosquitto" application for target (device) from qt creator (that is install on pc).

            For cross compilng i have use qmake version 4.8.7.

            and qt creator version is "Qt Creator 3.3.0 (opensource)"

            and for v

            @jsulm said in segmentation fault:

            Does the app crash in same way on host with Qt5?

            No, the application is not crash in PC.

            In pc i have use same code but qmake vwersion is 5.4.0

            @jsulm said in segmentation fault:

            Is it possible that you're mixing Qt4 and Qt5 on your target device? You can check this using "ldd EXECUTABLE" on your target.

            In target i have only qt 4 library and qmake are there.
            i think there is no qt 5 component in target device.

            @jsulm said in segmentation fault:

            Please do this on your target (in a terminal):

            sorry for this, but i have not ldd command on target device.
            if it is necessary than tell i have install and cross compile it for target device.

            sorry i dont know why this ldd cmd is not there in target device.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 16 Oct 2019, 05:42 last edited by
            #52

            @Milav said in segmentation fault:

            sorry i dont know why this ldd cmd is not there in target device

            This is not unusual. On limited devices manufacturers usually remove everything not needed when using the device.
            Is "file" command there?

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

            M 1 Reply Last reply 16 Oct 2019, 05:46
            0
            • J jsulm
              16 Oct 2019, 05:42

              @Milav said in segmentation fault:

              sorry i dont know why this ldd cmd is not there in target device

              This is not unusual. On limited devices manufacturers usually remove everything not needed when using the device.
              Is "file" command there?

              M Offline
              M Offline
              Milav
              wrote on 16 Oct 2019, 05:46 last edited by
              #53

              @jsulm said in segmentation fault:

              This is not unusual. On limited devices manufacturers usually remove everything not needed when using the device.
              Is "file" command there?

              Okay no problem.

              actually "file" cmd also not in target device.

              but in desktop pc i have "file" cmd so i execute file cmd with binary application file.

              here i have show output of that .

              tdp0009@tdp0009-desktop:~$ file qt-mosquitto 
              qt-mosquitto: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.6.32, not stripped
              
              

              i think you got your answer from above result.

              J 1 Reply Last reply 16 Oct 2019, 05:47
              0
              • M Milav
                16 Oct 2019, 05:46

                @jsulm said in segmentation fault:

                This is not unusual. On limited devices manufacturers usually remove everything not needed when using the device.
                Is "file" command there?

                Okay no problem.

                actually "file" cmd also not in target device.

                but in desktop pc i have "file" cmd so i execute file cmd with binary application file.

                here i have show output of that .

                tdp0009@tdp0009-desktop:~$ file qt-mosquitto 
                qt-mosquitto: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.6.32, not stripped
                
                

                i think you got your answer from above result.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 16 Oct 2019, 05:47 last edited by
                #54

                @Milav said in segmentation fault:

                32-bit LSB executable, ARM, EABI5

                Looks good if that's what your target device CPU is

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

                M 2 Replies Last reply 16 Oct 2019, 05:52
                0
                • J jsulm
                  16 Oct 2019, 05:47

                  @Milav said in segmentation fault:

                  32-bit LSB executable, ARM, EABI5

                  Looks good if that's what your target device CPU is

                  M Offline
                  M Offline
                  Milav
                  wrote on 16 Oct 2019, 05:52 last edited by
                  #55

                  @jsulm said in segmentation fault:

                  Looks good if that's what your target device CPU is

                  yes. it is ARM based 32-bit CPU.

                  1 Reply Last reply
                  0
                  • J jsulm
                    16 Oct 2019, 05:16

                    @Milav OK, maybe we should start from the beginning.
                    Do you cross compile from PC to device?
                    Does the app crash in same way on host with Qt5?
                    Is it possible that you're mixing Qt4 and Qt5 on your target device? You can check this using "ldd EXECUTABLE" on your target.
                    Please do this on your target (in a terminal):

                    file /opt/milav/qt-mosquitto
                    ldd /opt/milav/qt-mosquitto
                    

                    and post the output here.

                    M Offline
                    M Offline
                    Milav
                    wrote on 16 Oct 2019, 06:08 last edited by
                    #56

                    @jsulm said in segmentation fault:

                    ldd /opt/milav/qt-mosquitto

                    hello ,

                    i explore and find some of the cmd for ldd.

                    here i have show the output for ldd qt-mosquitto/

                      Shared library: [libmosquittopp.so.1]
                     0x00000001 (NEEDED)                     Shared library: [libmosquitto.so.1]
                     0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
                     0x00000001 (NEEDED)                     Shared library: [librt.so.1]
                     0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
                     0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
                     0x00000001 (NEEDED)                     Shared library: [libm.so.6]
                     0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
                     0x00000001 (NEEDED)                     Shared library: [libc.so.6]
                     0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
                    
                    

                    hope now you got your answer.

                    1 Reply Last reply
                    0
                    • J jsulm
                      16 Oct 2019, 05:47

                      @Milav said in segmentation fault:

                      32-bit LSB executable, ARM, EABI5

                      Looks good if that's what your target device CPU is

                      M Offline
                      M Offline
                      Milav
                      wrote on 16 Oct 2019, 09:10 last edited by
                      #57

                      @jsulm

                      Hello, have you got any solution?

                      J 1 Reply Last reply 16 Oct 2019, 10:26
                      0
                      • M Milav
                        16 Oct 2019, 09:10

                        @jsulm

                        Hello, have you got any solution?

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 16 Oct 2019, 10:26 last edited by
                        #58

                        @Milav Did you try to cross compile a simple application and run it on your device?

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

                        M 1 Reply Last reply 16 Oct 2019, 10:41
                        1
                        • J jsulm
                          16 Oct 2019, 10:26

                          @Milav Did you try to cross compile a simple application and run it on your device?

                          M Offline
                          M Offline
                          Milav
                          wrote on 16 Oct 2019, 10:41 last edited by
                          #59

                          @jsulm

                          yes, without mqtt module , i tried lot of application and it is working very fine..

                          J 1 Reply Last reply 16 Oct 2019, 11:25
                          0
                          • M Milav
                            16 Oct 2019, 10:41

                            @jsulm

                            yes, without mqtt module , i tried lot of application and it is working very fine..

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 16 Oct 2019, 11:25 last edited by
                            #60

                            @Milav Then I suggest to start with a minimal application and add mqtt functionality in small pieces to see when it starts to crash.

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

                            1 Reply Last reply
                            1
                            • M Milav
                              16 Oct 2019, 04:59

                              @Pablo-J-Rogina said in segmentation fault:

                              In addition, is there any compelling reason not to use the Qt MQTT module?
                              Have you try any of the Qt MQTT examples?

                              I use actually qt4.8.7 source for development so QMqtt is not build for this qt version, so that i do not use qmqtt class.

                              if you have any idea how to run QMqtt in qt 4.8.7 source than please tell me it is so helpful to me.

                              @Pablo-J-Rogina said in segmentation fault:

                              Could it be possible that you run such example AS IS, I mean just download/clone the code and try such example without any change.
                              If you manage to make it work, then you'll have the foundation to start adapting it to whatever you need/desire.

                              i actually tried same as is code for pc development and that is work fine.

                              but when i cross compiling the code for embedded target board than it gives segmentation error,

                              the difference between host pc and Embedded target board is only QT source.

                              Host pc => qmake (qt version 5.4.0 )
                              Embedded target => qmake (qt version 4.8.7)

                              hope you got my point.

                              if you have any query please tell me.

                              and please guys help me to sort out the problem.

                              i am also try another code for the same , but in that i have also suffer same problem.

                              Another code link :- link text

                              P Offline
                              P Offline
                              Pablo J. Rogina
                              wrote on 16 Oct 2019, 12:35 last edited by
                              #61

                              @Milav said in segmentation fault:

                              the difference between host pc and Embedded target board is only QT source.
                              Host pc => qmake (qt version 5.4.0 )
                              Embedded target => qmake (qt version 4.8.7)

                              You should have stated these settings from the very beginning... :-)

                              Anyway, could it be possible that you build Qt 4.8.7 for PC (host) and build your example again with that Qt version and run in PC to see what happens.

                              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
                              0

                              57/61

                              16 Oct 2019, 09:10

                              • Login

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