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. QtSerialPort windows static link
Qt 6.11 is out! See what's new in the release blog

QtSerialPort windows static link

Scheduled Pinned Locked Moved Installation and Deployment
8 Posts 4 Posters 9.8k Views 2 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.
  • P Offline
    P Offline
    pou_cz
    wrote on last edited by
    #1

    Hi,
    I use static build Qt4.8 on windows XP. Now I need use QtSerialPort library in my program. So I downloaded this library a compilated it. Every thing seems good (no error).
    So I create new Project with this library, compiling is ok, but linker take me a lot of error. But I included library Qserialport.a to linker.
    I added to serial_port.pro this lines:
    @
    CONFIG += serialport
    LIBS +=-lQtSerialPort
    @

    but linker take this error:
    @
    C:/MinGW/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory C:/Documents and Settings/pou/Desktop/serial_port' g++ -static -static-libgcc -Wl,-subsystem,windows -o debug\serial_ports.exe debug/main.o debug/mainwindow.o debug/text_porting.o debug/moc_mainwindow.o debug/moc_text_porting.o -L"z:\qt-static\QtSources\4.8.1\lib" -lmingw32 -lqtmaind -lQtSerialPortd -lQtSerialPort -lQtGuid -lsetupapi -lQtCore -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCored -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 mingw32-make.exe[1]: Leaving directory C:/Documents and Settings/pou/Desktop/serial_port'
    z:\qt-static\QtSources\4.8.1\lib\libQtCored.a(qcoreapplication.o): In function ZN23QCoreApplicationPrivate13checkInstanceEPKc': Z:\qt-static\QtSources\4.8.1\src\corelib/kernel/qcoreapplication.cpp:213: multiple definition of QCoreApplicationPrivate::checkInstance(char const*)'
    z:\qt-static\QtSources\4.8.1\lib\libQtCore.a(qcoreapplication.o):qcoreapplication.cpp:(.text+0x480): first defined here
    z:\qt-static\QtSources\4.8.1\lib\libQtCored.a(qcoreapplication.o): In function Z32qt_register_signal_spy_callbacksRK21QSignalSpyCallbackSet': Z:\qt-static\QtSources\4.8.1\src\corelib/kernel/qcoreapplication.cpp:225: multiple definition of qt_register_signal_spy_callbacks(QSignalSpyCallbackSet const&)'
    z:\qt-static\QtSources\4.8.1\lib\libQtCore.a(qcoreapplication.o):qcoreapplication.cpp:(.text+0x4b0): first defined here
    z:\qt-static\QtSources\4.8.1\lib\libQtCored.a(qcoreapplication.o): In function `qt_startup_hook':
    @

    Thank for answer!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      You can statically linked by other way:

      1. Comment in "qserialportglobal.h" for macro Q_DECL_IMPORT

      @
      #ifndef QT_STATIC

      if defined(QT_BUILD_SERIALPORT_LIB)

      define Q_SERIALPORT_EXPORT // Q_DECL_EXPORT

      else

      define Q_SERIALPORT_EXPORT // Q_DECL_IMPORT

      endif

      #else

      define Q_SERIALPORT_EXPORT

      #endif
      @

      1. Add direcrtly "serialport-lib.pri" to your project file *.pro:

      @
      include(<patch/to/pri>/serialport-lib.pri)
      @

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pou_cz
        wrote on last edited by
        #3

        Thank you for answer!
        Ok i comment this macro and add serialport-lib.pri to my project, now it send this error:
        @
        serialport-lib.pri:44:6: error: invalid preprocessing directive #MMP_RULES
        serialport-lib.pri:52:7: error: invalid preprocessing directive #FIXME
        serialport-lib.pri:53:6: error: invalid preprocessing directive #INCLUDEPATH

        serialport-lib.pri:1:1: error: 'INCLUDEPATH' does not name a type
        serialport-lib.pri:12:1: error: 'PUBLIC_HEADERS' does not name a type
        serialport-lib.pri:42:1: error: 'symbian' does not name a type
        serialport-lib.pri:66:1: error: 'unix' does not name a type
        serialport-lib.pri:87:1: error: 'HEADERS' does not name a type
        @

        Thank for answer! Jan Opravil

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,
          Looks like you included serialport-lib.pri in a header, that's wrong, you have to include it in your project pro file.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          0
          • K Offline
            K Offline
            kuzulis
            Qt Champions 2020
            wrote on last edited by
            #5

            UPD:

            1. Need comment only for Q_DECL_IMPORT macro in “qserialportglobal.h”:
              @
              ...

            else

            define Q_SERIALPORT_EXPORT //Q_DECL_IMPORT

            endif

            ...
            @

            1. Need to fix some compilation errors like:

            bq. E:\git\ng\123\qtserialport\src\serialport\qserialport.h:48: error: QtSerialPort/qserialportglobal.h: No such file or directory

            Just rename includes from:

            @
            #include <QtSerialPort/qserialportglobal.h>
            @

            to

            @
            #include <qserialportglobal.h>
            @

            and so forth...

            PS: This library is designed as a dynamic. Nobody checked and nobody build it as statically. So any problems related with the static building and linking - please resolve yourself.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pou_cz
              wrote on last edited by
              #6

              It still not work for me…(some compiler error)
              But thank!! and i accept this:
              “So any problems related with the static building and linking – please resolve yourself.”
              Now i link this library dynamic and it work.

              1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,
                Looks like you included serialport-lib.pri in a header, that's wrong, you have to include it in your project pro file.

                N Offline
                N Offline
                Narthan
                wrote on last edited by
                #7

                @SGaist How to configure Qserialport static to Qt4.8 in ubuntu12.04

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi and welcome to devnet,

                  Unless you really need it as a separated module, do as @kuzulis suggested: include the serialport-lib.pri file in your .pro file

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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