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. Problems when adding serialport module in Qt project

Problems when adding serialport module in Qt project

Scheduled Pinned Locked Moved Solved General and Desktop
serialportqserialport
58 Posts 7 Posters 31.0k 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.
  • P Pablo J. Rogina
    14 Jun 2018, 13:07

    @douglas if you could please show us

    How did you cross-compile for your target device?

    It may help understanding your issue

    D Offline
    D Offline
    douglas
    wrote on 14 Jun 2018, 14:48 last edited by
    #35

    @Pablo-J.-Rogina , after the Qt Creator installation, I followed the indication from 2.1 to 2.7 chapter here:
    http://variwiki.com/index.php?title=Yocto_Qt_Creator&release=RELEASE_MORTY_V1.0_DART-6UL#QtCreator_configuration
    in which, as far as I see, the environment is configured to cross-compile for my target device.
    Now, I am able to create a simple GUI application and run it on my target device, but I can't add the serialport component (in order to manage a RS485 communication) in my project.
    Unfortunatelly, I'm a beginner in this matter!
    Thanks a lot!

    P 1 Reply Last reply 14 Jun 2018, 18:30
    0
    • D douglas
      14 Jun 2018, 14:48

      @Pablo-J.-Rogina , after the Qt Creator installation, I followed the indication from 2.1 to 2.7 chapter here:
      http://variwiki.com/index.php?title=Yocto_Qt_Creator&release=RELEASE_MORTY_V1.0_DART-6UL#QtCreator_configuration
      in which, as far as I see, the environment is configured to cross-compile for my target device.
      Now, I am able to create a simple GUI application and run it on my target device, but I can't add the serialport component (in order to manage a RS485 communication) in my project.
      Unfortunatelly, I'm a beginner in this matter!
      Thanks a lot!

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 14 Jun 2018, 18:30 last edited by
      #36

      @douglas said in Problems when adding serialport module in Qt project:

      Now, I am able to create a simple GUI application and run it on my target device

      Ok, that's a great step. Reading briefly the link you posted to that wiki page, I assume you setup your environment in a Linux PC and using Qt Creator there, you built that simple GUI app that Qt Creator deployed and run in your device.

      If that's correct, I'd try the following:

      1. from command line in let's say /home/douglas/projects do
      cd /home/douglas/projects
      git clone git://code.qt.io/qt/qtserialport.git -b 5.9
      cd qtserialport
      

      so you should now have a folder /home/douglas/projects/qtserialport will sources for Qt serial port module release 5.9 (the Qt release should match what you have in your dev environment/device, you didn't stated it so far).
      2. run commands:

      /opt/fslc-x11/2.2.1/sysroot/x86_64-fslcsdk-linux/usr/bin/qt5/qmake
      make
      make install
      

      once build and install finishes, you should have the .so shared library and headers into the proper location under your host PC (I couldn't figure out the proper location from the wiki page). But look for something like this (version shuold be the one you cloned...):

      ./include/QtSerialPort/qtserialportversion.h
      ./include/QtSerialPort/qserialportinfo.h
      ./include/QtSerialPort/qserialportglobal.h
      ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialport_p.h
      ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialportinfo_p.h
      ./include/QtSerialPort/qserialport.h
      

      and

      ./lib/libQt5SerialPort.so
      

      if you succeed here, then you should be able to create a project file (.pro) for your application and add the serial port modulie like this:

      ...
      QT += serialport
      ...
      

      and the magic will flow.

      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

      D 1 Reply Last reply 18 Jun 2018, 06:47
      2
      • P Pablo J. Rogina
        14 Jun 2018, 18:30

        @douglas said in Problems when adding serialport module in Qt project:

        Now, I am able to create a simple GUI application and run it on my target device

        Ok, that's a great step. Reading briefly the link you posted to that wiki page, I assume you setup your environment in a Linux PC and using Qt Creator there, you built that simple GUI app that Qt Creator deployed and run in your device.

        If that's correct, I'd try the following:

        1. from command line in let's say /home/douglas/projects do
        cd /home/douglas/projects
        git clone git://code.qt.io/qt/qtserialport.git -b 5.9
        cd qtserialport
        

        so you should now have a folder /home/douglas/projects/qtserialport will sources for Qt serial port module release 5.9 (the Qt release should match what you have in your dev environment/device, you didn't stated it so far).
        2. run commands:

        /opt/fslc-x11/2.2.1/sysroot/x86_64-fslcsdk-linux/usr/bin/qt5/qmake
        make
        make install
        

        once build and install finishes, you should have the .so shared library and headers into the proper location under your host PC (I couldn't figure out the proper location from the wiki page). But look for something like this (version shuold be the one you cloned...):

        ./include/QtSerialPort/qtserialportversion.h
        ./include/QtSerialPort/qserialportinfo.h
        ./include/QtSerialPort/qserialportglobal.h
        ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialport_p.h
        ./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialportinfo_p.h
        ./include/QtSerialPort/qserialport.h
        

        and

        ./lib/libQt5SerialPort.so
        

        if you succeed here, then you should be able to create a project file (.pro) for your application and add the serial port modulie like this:

        ...
        QT += serialport
        ...
        

        and the magic will flow.

        D Offline
        D Offline
        douglas
        wrote on 18 Jun 2018, 06:47 last edited by
        #37

        @Pablo-J.-Rogina Thanks a lot for your post, I'll now begin to put it into practice. I have just one doubt: if I run:

        qmake --version
        

        I obtain:

        QMake version 2.01a
        Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu
        

        So, if I'm not wrong, the installed version of Qt is the 4.8.7 (quite old). When you stated, in your #1 step, "git clone git://code.qt.io/qt/qtserialport.git -b 5.9" were you assuming my Qt version was 5.9? In other words, the serialport version and the installed qt version should be the same?
        If so, how can I upgrade from my actual Qt version to the latest one?
        Thanks a lot!

        A 1 Reply Last reply 18 Jun 2018, 06:54
        0
        • D douglas
          18 Jun 2018, 06:47

          @Pablo-J.-Rogina Thanks a lot for your post, I'll now begin to put it into practice. I have just one doubt: if I run:

          qmake --version
          

          I obtain:

          QMake version 2.01a
          Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu
          

          So, if I'm not wrong, the installed version of Qt is the 4.8.7 (quite old). When you stated, in your #1 step, "git clone git://code.qt.io/qt/qtserialport.git -b 5.9" were you assuming my Qt version was 5.9? In other words, the serialport version and the installed qt version should be the same?
          If so, how can I upgrade from my actual Qt version to the latest one?
          Thanks a lot!

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 18 Jun 2018, 06:54 last edited by
          #38

          @douglas

          you can have multiple Qt versions installed, so please check carefully which one you use.

          For the qmakes that are not in PATH, you have to specify the full path, e.g. /opt/Qt/5.9.0/bin/qmake

          Regards

          Qt has to stay free or it will die.

          D 1 Reply Last reply 18 Jun 2018, 06:59
          1
          • A aha_1980
            18 Jun 2018, 06:54

            @douglas

            you can have multiple Qt versions installed, so please check carefully which one you use.

            For the qmakes that are not in PATH, you have to specify the full path, e.g. /opt/Qt/5.9.0/bin/qmake

            Regards

            D Offline
            D Offline
            douglas
            wrote on 18 Jun 2018, 06:59 last edited by
            #39

            @aha_1980 how I can upgrade to the latest Qt version and set it as default in my project? After this I will be sure to use the Qt version 5.9 and I will apply the steps suggested by @Pablo-J-Rogina
            Thank you!

            A 1 Reply Last reply 18 Jun 2018, 08:09
            0
            • D douglas
              18 Jun 2018, 06:59

              @aha_1980 how I can upgrade to the latest Qt version and set it as default in my project? After this I will be sure to use the Qt version 5.9 and I will apply the steps suggested by @Pablo-J-Rogina
              Thank you!

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 18 Jun 2018, 08:09 last edited by
              #40

              @douglas

              First you should find out which Qt versions you have on your computer. Qt 4.8.7 is surely from Ubuntu and is a native Qt - you build programs that run on your computer. What you want, is a cross Qt, to run programs on your embedded device.

              As you said you have already done this, you surely have a second Qt version (I cannot tell you which one it is). And this Qt version has a qmake which you need to call to compile Qt programs against this Qt library.

              Regards

              Qt has to stay free or it will die.

              D 1 Reply Last reply 18 Jun 2018, 09:02
              1
              • A aha_1980
                18 Jun 2018, 08:09

                @douglas

                First you should find out which Qt versions you have on your computer. Qt 4.8.7 is surely from Ubuntu and is a native Qt - you build programs that run on your computer. What you want, is a cross Qt, to run programs on your embedded device.

                As you said you have already done this, you surely have a second Qt version (I cannot tell you which one it is). And this Qt version has a qmake which you need to call to compile Qt programs against this Qt library.

                Regards

                D Offline
                D Offline
                douglas
                wrote on 18 Jun 2018, 09:02 last edited by
                #41

                @aha_1980 Thanks. In Qt Creator I set Qt 5.7.1 in the "Qt Version" for the selected kit for my project. Now I can add the serialport module in my .pro file and build the app, but when I try to run it on my target device, the application does not start and the following error appears:

                error while loading shared libraries: libQt5SerialPort.so.5: cannot open shared object file: No such file or directory
                

                Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?
                Thank you!

                A 1 Reply Last reply 18 Jun 2018, 09:11
                0
                • D douglas
                  18 Jun 2018, 09:02

                  @aha_1980 Thanks. In Qt Creator I set Qt 5.7.1 in the "Qt Version" for the selected kit for my project. Now I can add the serialport module in my .pro file and build the app, but when I try to run it on my target device, the application does not start and the following error appears:

                  error while loading shared libraries: libQt5SerialPort.so.5: cannot open shared object file: No such file or directory
                  

                  Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?
                  Thank you!

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 18 Jun 2018, 09:11 last edited by
                  #42

                  @douglas said in Problems when adding serialport module in Qt project:

                  Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?

                  You're already on the right track. You need to cross-compile QtSerialPort for your embedded device, and then you need to deploy (copy over) these libraries to the device, because your final app is also running there.

                  Qt has to stay free or it will die.

                  D 2 Replies Last reply 18 Jun 2018, 09:35
                  1
                  • A aha_1980
                    18 Jun 2018, 09:11

                    @douglas said in Problems when adding serialport module in Qt project:

                    Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?

                    You're already on the right track. You need to cross-compile QtSerialPort for your embedded device, and then you need to deploy (copy over) these libraries to the device, because your final app is also running there.

                    D Offline
                    D Offline
                    douglas
                    wrote on 18 Jun 2018, 09:35 last edited by
                    #43

                    @aha_1980 Ok,thanks! I just did the following on my host PC:

                    $ git clone git://code.qt.io/qt/qtserialport.git
                    $ mkdir qtserialport-build
                    $ cd qtserialport-build
                    $ qmake ../qtserialport/qtserialport.pro
                    

                    but the last command (qmake) gives the following:

                    Project MESSAGE: Cannot build current QtSerialPort sources with Qt version 4.8.7.
                    Project ERROR: Use at least Qt 5.0.0 or try to download QtSerialPort for Qt4.
                    

                    It is clear that I need to use a newer qmake, perhaps the default one is an older version. How can I run that command with a qmake version 5? Where should it be located? Or how can I "change the default one"?
                    Thanks for your patience.

                    1 Reply Last reply
                    0
                    • A aha_1980
                      18 Jun 2018, 09:11

                      @douglas said in Problems when adding serialport module in Qt project:

                      Is it related to the serialport module that is not cross compiled or have I to install some dependencies on the target device itself?

                      You're already on the right track. You need to cross-compile QtSerialPort for your embedded device, and then you need to deploy (copy over) these libraries to the device, because your final app is also running there.

                      D Offline
                      D Offline
                      douglas
                      wrote on 18 Jun 2018, 09:52 last edited by
                      #44

                      @aha_1980 Done, I found the qmake for version 5 and run the qmake command.
                      Now, when I run the

                      make
                      make install
                      

                      this error appears:

                      fatal error: qdeadlinetimer.h: File o directory non esistente
                      compilation terminated.
                      

                      Which can be the solution?

                      A 1 Reply Last reply 18 Jun 2018, 10:13
                      0
                      • D douglas
                        18 Jun 2018, 09:52

                        @aha_1980 Done, I found the qmake for version 5 and run the qmake command.
                        Now, when I run the

                        make
                        make install
                        

                        this error appears:

                        fatal error: qdeadlinetimer.h: File o directory non esistente
                        compilation terminated.
                        

                        Which can be the solution?

                        A Offline
                        A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on 18 Jun 2018, 10:13 last edited by
                        #45

                        @douglas you are tryin to compile a new QSerialPort against an older Qt.

                        Add a git checkout -b v5.7.1 directly after the git clone command and rebuild.

                        Qt has to stay free or it will die.

                        D 1 Reply Last reply 18 Jun 2018, 10:37
                        0
                        • A aha_1980
                          18 Jun 2018, 10:13

                          @douglas you are tryin to compile a new QSerialPort against an older Qt.

                          Add a git checkout -b v5.7.1 directly after the git clone command and rebuild.

                          D Offline
                          D Offline
                          douglas
                          wrote on 18 Jun 2018, 10:37 last edited by
                          #46

                          @aha_1980 I add "git checkout -b v5.7.1" , but the qdeadlinetimer.h error shown above still remains during the make procedure. Any hints?

                          J 1 Reply Last reply 18 Jun 2018, 10:41
                          0
                          • D douglas
                            18 Jun 2018, 10:37

                            @aha_1980 I add "git checkout -b v5.7.1" , but the qdeadlinetimer.h error shown above still remains during the make procedure. Any hints?

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 18 Jun 2018, 10:41 last edited by
                            #47

                            @douglas Did you try to delete the build folder, create new one and to start from there?

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

                            D 1 Reply Last reply 18 Jun 2018, 11:59
                            1
                            • J jsulm
                              18 Jun 2018, 10:41

                              @douglas Did you try to delete the build folder, create new one and to start from there?

                              D Offline
                              D Offline
                              douglas
                              wrote on 18 Jun 2018, 11:59 last edited by
                              #48

                              @jsulm Yes, I did. I always obtain the

                              fatal error: qdeadlinetimer.h: File o directory non esistente
                              compilation terminated.
                              
                              A 1 Reply Last reply 18 Jun 2018, 12:10
                              0
                              • D douglas
                                18 Jun 2018, 11:59

                                @jsulm Yes, I did. I always obtain the

                                fatal error: qdeadlinetimer.h: File o directory non esistente
                                compilation terminated.
                                
                                A Offline
                                A Offline
                                aha_1980
                                Lifetime Qt Champion
                                wrote on 18 Jun 2018, 12:10 last edited by
                                #49

                                @douglas please send the output of git status

                                Qt has to stay free or it will die.

                                D 1 Reply Last reply 18 Jun 2018, 13:17
                                0
                                • A aha_1980
                                  18 Jun 2018, 12:10

                                  @douglas please send the output of git status

                                  D Offline
                                  D Offline
                                  douglas
                                  wrote on 18 Jun 2018, 13:17 last edited by
                                  #50

                                  @aha_1980

                                  Sul branch v5.7.1
                                  Untracked files:
                                    (use "git add <file>..." to include in what will be committed)
                                  
                                  	./
                                  
                                  nothing added to commit but untracked files present (use "git add" to track)
                                  

                                  Am I missing something?

                                  A 1 Reply Last reply 18 Jun 2018, 14:17
                                  0
                                  • D douglas
                                    18 Jun 2018, 13:17

                                    @aha_1980

                                    Sul branch v5.7.1
                                    Untracked files:
                                      (use "git add <file>..." to include in what will be committed)
                                    
                                    	./
                                    
                                    nothing added to commit but untracked files present (use "git add" to track)
                                    

                                    Am I missing something?

                                    A Offline
                                    A Offline
                                    aha_1980
                                    Lifetime Qt Champion
                                    wrote on 18 Jun 2018, 14:17 last edited by
                                    #51

                                    @douglas Looks good so far.

                                    But let's move slowly. I re-read you post from 5 hours ago:

                                    @aha_1980 Thanks. In Qt Creator I set Qt 5.7.1 in the "Qt Version" for the selected kit for my project. Now I can add the serialport module in my .pro file and build the app

                                    If you can build the app, then you already have the serialport module!

                                    but when I try to run it on my target device, the application does not start and the following error appears:

                                    But you don't have the libraries on your target device.

                                    Qt has to stay free or it will die.

                                    D 1 Reply Last reply 18 Jun 2018, 14:26
                                    0
                                    • A aha_1980
                                      18 Jun 2018, 14:17

                                      @douglas Looks good so far.

                                      But let's move slowly. I re-read you post from 5 hours ago:

                                      @aha_1980 Thanks. In Qt Creator I set Qt 5.7.1 in the "Qt Version" for the selected kit for my project. Now I can add the serialport module in my .pro file and build the app

                                      If you can build the app, then you already have the serialport module!

                                      but when I try to run it on my target device, the application does not start and the following error appears:

                                      But you don't have the libraries on your target device.

                                      D Offline
                                      D Offline
                                      douglas
                                      wrote on 18 Jun 2018, 14:26 last edited by
                                      #52

                                      @aha_1980 Thanks, I understand. In order to obtain those libraries on my target device is something that I should copy from my host PC onto the device itself or I should install directly on the device side in any way?

                                      A P 2 Replies Last reply 18 Jun 2018, 14:29
                                      0
                                      • D douglas
                                        18 Jun 2018, 14:26

                                        @aha_1980 Thanks, I understand. In order to obtain those libraries on my target device is something that I should copy from my host PC onto the device itself or I should install directly on the device side in any way?

                                        A Offline
                                        A Offline
                                        aha_1980
                                        Lifetime Qt Champion
                                        wrote on 18 Jun 2018, 14:29 last edited by
                                        #53

                                        @douglas In the most easy and hacky way, just copy the needed *.so files to the other Qt *.so files on your device.

                                        Depending on your cross toolchain, there may be a more clean way (like building a new image), but that - as said - depends on you toolchain.

                                        Qt has to stay free or it will die.

                                        1 Reply Last reply
                                        1
                                        • D douglas
                                          18 Jun 2018, 14:26

                                          @aha_1980 Thanks, I understand. In order to obtain those libraries on my target device is something that I should copy from my host PC onto the device itself or I should install directly on the device side in any way?

                                          P Offline
                                          P Offline
                                          Pablo J. Rogina
                                          wrote on 18 Jun 2018, 14:34 last edited by
                                          #54

                                          @douglas as @aha_1980 said, maybe easiest way is to copy the serialport module *.so the same way you're deploying the file(s) for your application. Perhaps at the beginning it's easy to copy the shared library into same folder as application's executable

                                          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

                                          D 1 Reply Last reply 18 Jun 2018, 14:47
                                          0

                                          44/58

                                          18 Jun 2018, 09:52

                                          • Login

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