Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] Adding QtSerialPort to 4.6.3

[Solved] Adding QtSerialPort to 4.6.3

Scheduled Pinned Locked Moved Installation and Deployment
16 Posts 3 Posters 10.5k 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.
  • M Offline
    M Offline
    McLion
    wrote on 9 Jul 2014, 12:45 last edited by
    #1

    Hi

    I am trying to add the QtSerialPort to my Qt 4.6.3.
    I have copied all the sources downloaded into a subfolder "QtSerialPort" into my project folder.
    I've added to project.pro:
    @CONFIG += serialport
    INCLUDEPATH += ./QtSerialPort/include/QtSerialPort
    include(QtSerialPort/src/serialport/qt4support/install-helper.pri)@

    Building on windows now returns (excerpt):
    @14:40:47: Starte "c:\qtsdk\desktop\qt\4.6.3\bin\qmake.exe" L:\target\src\sd\aixsolve\qtgui\src\qtgui.pro -r -spec win32-g++ "CONFIG+=release"
    Ein Unterverzeichnis oder eine Datei mit dem Namen "\include\QtSerialPort" existiert bereits.
    Ein Unterverzeichnis oder eine Datei mit dem Namen "\include\QtSerialPort" existiert bereits.
    Ein Unterverzeichnis oder eine Datei mit dem Namen "\include\QtSerialPort" existiert bereits.
    14:40:49: Der Prozess "c:\qtsdk\desktop\qt\4.6.3\bin\qmake.exe" wurde normal beendet.@

    and building on linux returns (excerpt):
    @mkdir: kann Verzeichnis „/include“ nicht anlegen: Keine Berechtigung
    sh: cannot create /include/QtSerialPort/QSerialPort: Directory nonexistent
    sh: cannot create /include/QtSerialPort/QSerialPortInfo: Directory nonexistent
    QtSerialPort/src/serialport/qt4support/src/qlockfile.cpp:42:23: fatal error: qlockfile.h: No such file or directory
    compilation terminated.@

    Can anybody help me with this?
    What do I need to do to have QtSerialPort with 4.6.3?

    Thanks a lot!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 9 Jul 2014, 13:43 last edited by
      #2

      At first, do you read "WIKI":https://qt-project.org/wiki/QtSerialPort?

      Briefly:

      1. Try to compile QtSerialPort separately
      2. If there are errors of compilation, to correct them and to try to rebuild again and again.
      3. Try to install of compiled QtSerialPort into your Qt 4.6.3.
      4. Create an empty Qt project and to write to *.pro file:
        @
        CONFIG += serialport
        @
        and try to compile (to check of successfully linking of QtSerialPort with your empty project).
      5. If there are errors then try to check existence of *.so libraries, the *.prf and the *.h files in your Qt 4.6.3.
      6. If no files available, try to repeat from item 1 again. Or try to copy/paste manually desired files into your Qt 4.6.3 place.
      7. If all fine, then make item 4 for your project.

      That will do.

      Upd: For me doesn't excite as you earlier included the QextSerialPort, since the QtSerialPort has the own laws, and has nothing in common with QextSerialPort. Therefore simply don't try to make analogy. Therefore if you have not enough experience in Qt and in programming, then please do all items how I talk. :)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        McLion
        wrote on 9 Jul 2014, 13:58 last edited by
        #3

        I read the wiki over and over. The explanations are not very detailed.
        I'll try again with your instructions and post back.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          McLion
          wrote on 9 Jul 2014, 14:26 last edited by
          #4

          OK, I am now trying to simply add it to my local Qt installation and build it under windows. Let's move it to Linux later.

          • I copied to "C:\QtSDK\Desktop\Qt\4.6.3\src\qt-qtserialport"
          • I opened serialport.pro
          • Did Build settings
          • Replaced QElapsedTimer with QTime
          • changed include path in qserialportinfo_win.cpp #include "C:\QtSDK\mingw\include\ddk\cfgmgr32.h"
          • Changed include path in qserialport_win.cpp to #include "qt4support/include/QtCore/qwineventnotifier.h"
            and now getting

          @mingw32-make.exe[1]: Leaving directory `C:/QtSDK/Desktop/Qt/4.6.3/src/qt-qtserialport/src/serialport-build-desktop-Qt_4_6_3_for_Desktop_-_MinGW_Release'
          ..\serialport\qserialportinfo_win.cpp: In static member function 'static QList<QSerialPortInfo> QSerialPortInfo::availablePorts()':
          ..\serialport\qserialportinfo_win.cpp:258: error: 'find_if' is not a member of 'std'
          ..\serialport\qserialportinfo_win.cpp:307: error: 'find_if' is not a member of 'std'@

          1 Reply Last reply
          0
          • M Offline
            M Offline
            McLion
            wrote on 9 Jul 2014, 15:18 last edited by
            #5

            Added #include <algorithm> .... and moving further

            1 Reply Last reply
            0
            • M Offline
              M Offline
              McLion
              wrote on 9 Jul 2014, 15:28 last edited by
              #6

              I think I am missing this step because the libraries are built but not installed:

              • add a new make “Build Step” and write to the “Make arguments” the install target

              ... I am not really sure how to do this ?!?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                McLion
                wrote on 9 Jul 2014, 15:55 last edited by
                #7

                ... found it:

                • Switch to Projects Mode: press Ctrl+5.
                • On Build Settings tab under Build Steps click on Add Build Step.
                • Choose Make from the menu.
                • Write install into Make arguments: text input box.

                .. libraries are installed in local 4.6.3 on windows. :)
                ... moving forward ...

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  McLion
                  wrote on 9 Jul 2014, 16:33 last edited by
                  #8

                  Including into a new empty project does not work, returning:
                  @release/main.o:main.cpp:(.text+0x66): undefined reference to _imp___ZN15QSerialPortInfo14availablePortsEv' release/main.o:main.cpp:(.text+0xf9): undefined reference to _imp___ZNK15QSerialPortInfo8portNameEv'
                  release/main.o:main.cpp:(.text+0x23b): undefined reference to _imp___ZNK15QSerialPortInfo11descriptionEv' release/main.o:main.cpp:(.text+0x374): undefined reference to _imp___ZNK15QSerialPortInfo12manufacturerEv'
                  release/main.o:main.cpp:(.text+0x4ab): undefined reference to _imp___ZN11QSerialPortC1EP7QObject' release/main.o:main.cpp:(.text+0x4be): undefined reference to _imp___ZN11QSerialPort7setPortERK15QSerialPortInfo'
                  release/main.o:main.cpp:(.text+0x4d5): undefined reference to _imp___ZN11QSerialPort4openE6QFlagsIN9QIODevice12OpenModeFlagEE' release/main.o:main.cpp:(.text+0x4e2): undefined reference to _imp___ZN11QSerialPort5closeEv'
                  release/main.o:main.cpp:(.text+0x4eb): undefined reference to _imp___ZN11QSerialPortD1Ev' release/main.o:main.cpp:(.text+0x94a): undefined reference to _imp___ZN11QSerialPortD1Ev'
                  release/main.o:main.cpp:(.text$_ZN5QListI15QSerialPortInfoE4freeEPN9QListData4DataE[QList<QSerialPortInfo>::free(QListData::Data*)]+0x36): undefined reference to _imp___ZN15QSerialPortInfoD1Ev' release/main.o:main.cpp:(.text$_ZN5QListI15QSerialPortInfoE13detach_helperEv[QList<QSerialPortInfo>::detach_helper()]+0x68): undefined reference to imp___ZN15QSerialPortInfoC1ERKS'
                  release/main.o:main.cpp:(.text$_ZN5QListI15QSerialPortInfoE13detach_helperEv[QList<QSerialPortInfo>::detach_helper()]+0xb6): undefined reference to `_imp___ZN15QSerialPortInfoD1Ev'
                  @

                  It installed .dll to /bin, .h to /include/QtSerialPort, .a, lib.dll and .prl to /lib. So far, this seems ok to me but it still returns the errors above.

                  Any idea?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    McLion
                    wrote on 9 Jul 2014, 17:01 last edited by
                    #9

                    Found it. If its done like in the wiki with adding
                    @CONFIG += serialport@

                    to the pro, it does not work.
                    I had to manually copy the prf from the sources and add:

                    @include(C:\QtSDK\Desktop\Qt\4.6.3\lib\serialport.prf)@

                    to the pro file (for what ever this file is for ?!?)
                    Finally, it runs under windows ... now I'll try to port it to my eLinux environment .. which will be trickier, I assume.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kuzulis
                      Qt Champions 2020
                      wrote on 9 Jul 2014, 17:39 last edited by
                      #10

                      The serialport.prf should be in \mkspecs\features\ in your Qt place. Then CONFIG += serialport should be work correctly.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        McLion
                        wrote on 10 Jul 2014, 06:43 last edited by
                        #11

                        Perfect! Thanks a lot.
                        Now .. moving to Linux ... I'll keep this thread updated

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          McLion
                          wrote on 10 Jul 2014, 12:56 last edited by
                          #12

                          Needed some changes to the sources. However, one line of code still bugs me:

                          @const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());@

                          msecsTo is not available in QDateTime in 4.6.3.
                          Any idea?

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kuzulis
                            Qt Champions 2020
                            wrote on 10 Jul 2014, 14:00 last edited by
                            #13

                            You can do not use QLockFile.. Just exclude this module/code from compilation (e.g. comments out some places and so on).

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              McLion
                              wrote on 10 Jul 2014, 14:38 last edited by
                              #14

                              Thanks. Decided to replace
                              @const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());
                              return staleLockTime > 0 && age > staleLockTime;
                              @
                              with
                              @return staleLockTime > 0 && (QDateTime::currentDateTime() > QFileInfo(fileName).lastModified().addMSecs(staleLockTime));@

                              It works! :)
                              Just compiled for my eLinux and used the basics from the wiki reading out port names. Going to replace qextserialport with QtSerialPort now and hope it helpes in solving my communication issue.

                              Thanks for your support and patience.

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                Mirgos
                                wrote on 20 Feb 2015, 10:07 last edited by
                                #15

                                [quote author="McLion" date="1404925315"]Found it. If its done like in the wiki with adding
                                @CONFIG += serialport@

                                to the pro, it does not work.
                                I had to manually copy the prf from the sources and add:

                                @include(C:\QtSDK\Desktop\Qt\4.6.3\lib\serialport.prf)@

                                to the pro file (for what ever this file is for ?!?)
                                Finally, it runs under windows ... now I'll try to port it to my eLinux environment .. which will be trickier, I assume.
                                [/quote]

                                Did the same, althought serialport.prf is in mkspec/features directory and I've added CONFIG += serialport in *.pro file. Works as intended

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  Mirgos
                                  wrote on 20 Feb 2015, 10:07 last edited by
                                  #16

                                  [quote author="McLion" date="1404925315"]Found it. If its done like in the wiki with adding
                                  @CONFIG += serialport@

                                  to the pro, it does not work.
                                  I had to manually copy the prf from the sources and add:

                                  @include(C:\QtSDK\Desktop\Qt\4.6.3\lib\serialport.prf)@

                                  to the pro file (for what ever this file is for ?!?)
                                  Finally, it runs under windows ... now I'll try to port it to my eLinux environment .. which will be trickier, I assume.
                                  [/quote]

                                  Did the same, althought serialport.prf is in mkspec/features directory and I've added CONFIG += serialport in *.pro file. Works as intended

                                  1 Reply Last reply
                                  0

                                  • Login

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