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. Qt6 QSerialPort qmake vs cmake
Forum Updated to NodeBB v4.3 + New Features

Qt6 QSerialPort qmake vs cmake

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 890 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 Offline
    M Offline
    MScottM
    wrote on last edited by
    #1

    Hello,

    I am running on Qt 6:
    Qt Creator 7.0.1
    Based on Qt 6.2.3 (MSVC 2019, 64 bit)
    Built on Apr 26 2022 01:23:20

    I can open and run the QSerialPort async reader and writer examples with no issues. I'm now trying to adapt the code to my own purposes and have started a CMake project (MSCV2019). I copy/pasted the code from the reader example and am trying to run it verbatim in my project. When I do it fails with 'LNK2019: unresolved external symbol' errors (8 of them), all related to QSerialPort methods.

    I'm assuming that I haven't set something up correctly in my overall build but as a beginner with CMake/MSCV I'm not sure how to figure it out. Besides the CMakeLists.txt vs .pro difference, I noticed that I had to change the #include <QSerialPort> in the example file to #include <QtSerialPort/QSerialPort> for it to be found (I added 'SerialPort' to my CMakeLists.txt REQUIRED COMPONENTS already).

    Any pointers on figuring this out are appreciated - I know I'm in a learning curve right now...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      also
      target_link_libraries(mytarget PRIVATE Qt6::SerialPort)
      ?

      1 Reply Last reply
      2
      • M Offline
        M Offline
        MScottM
        wrote on last edited by
        #3

        @mrjj

        That did it! Simple, thank you.

        mrjjM 1 Reply Last reply
        1
        • M MScottM

          @mrjj

          That did it! Simple, thank you.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @MScottM
          Hi
          Super :)
          Please note (since learning)
          that the docs can be used to know such things

          alt text

          https://doc.qt.io/qt-6/qserialport.html

          1 Reply Last reply
          1

          • Login

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