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. Application doesn't find Qt libraries during compilation process
Forum Updated to NodeBB v4.3 + New Features

Application doesn't find Qt libraries during compilation process

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 461 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.
  • T Offline
    T Offline
    tankist
    wrote on last edited by
    #1

    I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:

    QT -= gui
    CONFIG += c++11 console serialport network
    CONFIG -= app_bundle
    
    SOURCES += \
            main.cpp
    
    RESOURCES += \
        resources.qrc
    

    The application won't build because tons of errors:

    undefined reference to `_imp___ZN11QSerialPortC1EP7QObject'
    undefined reference to `_imp___ZN5QMenuC1EP7QWidget'
    

    and so on.
    I seems like Qt libraries don't connected to the application.

    How to fix that?

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • T tankist

      I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:

      QT -= gui
      CONFIG += c++11 console serialport network
      CONFIG -= app_bundle
      
      SOURCES += \
              main.cpp
      
      RESOURCES += \
          resources.qrc
      

      The application won't build because tons of errors:

      undefined reference to `_imp___ZN11QSerialPortC1EP7QObject'
      undefined reference to `_imp___ZN5QMenuC1EP7QWidget'
      

      and so on.
      I seems like Qt libraries don't connected to the application.

      How to fix that?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @tankist Please post the build log, especially the linker calls.

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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #3
        QT += network widgets serialport 
        

        Module names should be added/removed in QT, not CONFIG .
        And you need to add widgets for QMenu since you removed gui.
        [Added]
        Ah, seems widgets depends on gui, so adding widgets will add gui again. I guess you should not remove gui if you want use QMenu.

        jsulmJ 1 Reply Last reply
        4
        • B Bonnie
          QT += network widgets serialport 
          

          Module names should be added/removed in QT, not CONFIG .
          And you need to add widgets for QMenu since you removed gui.
          [Added]
          Ah, seems widgets depends on gui, so adding widgets will add gui again. I guess you should not remove gui if you want use QMenu.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Bonnie Good catch, did not realized OP added modules to CONFIG, not QT

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

          1 Reply Last reply
          0
          • T tankist

            I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:

            QT -= gui
            CONFIG += c++11 console serialport network
            CONFIG -= app_bundle
            
            SOURCES += \
                    main.cpp
            
            RESOURCES += \
                resources.qrc
            

            The application won't build because tons of errors:

            undefined reference to `_imp___ZN11QSerialPortC1EP7QObject'
            undefined reference to `_imp___ZN5QMenuC1EP7QWidget'
            

            and so on.
            I seems like Qt libraries don't connected to the application.

            How to fix that?

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #5

            @tankist said in Application doesn't find Qt libraries during compilation process:

            system tray icon

            It is not working like that...QSysTrayIcon is a QWidget and therefore needs the QtWidget module. Even though when your intention is to build a "background" app... The above mentioned class(es) (including QMenu what you are probably gonna use as a popup when clicking the icon) requires some GUI components.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tankist
              wrote on last edited by
              #6

              Thank you, guys. It was just my mistake. Now configuration looks like

              QT -= gui
              QT += serialport network widgets
              
              CONFIG += c++11 console
              

              and the application build process succeeded.
              The only issue is widgets are not created. Application crashed on

              menu = new QMenu();
              

              with error

              QWidget: Cannot create a QWidget without QApplication
              

              I have no idea what was wrong because I created QApplication object before.

              int main(int argc, char *argv[])
              {
              	a = new QCoreApplication(argc, argv);
              	sysMon = new SystemMonitor();
              

              Maybe it was wrong idea at all to create console application with system tray icon?

              B 1 Reply Last reply
              0
              • T tankist

                Thank you, guys. It was just my mistake. Now configuration looks like

                QT -= gui
                QT += serialport network widgets
                
                CONFIG += c++11 console
                

                and the application build process succeeded.
                The only issue is widgets are not created. Application crashed on

                menu = new QMenu();
                

                with error

                QWidget: Cannot create a QWidget without QApplication
                

                I have no idea what was wrong because I created QApplication object before.

                int main(int argc, char *argv[])
                {
                	a = new QCoreApplication(argc, argv);
                	sysMon = new SystemMonitor();
                

                Maybe it was wrong idea at all to create console application with system tray icon?

                B Offline
                B Offline
                Bonnie
                wrote on last edited by Bonnie
                #7

                @tankist said in Application doesn't find Qt libraries during compilation process:

                Maybe it was wrong idea at all to create console application with system tray icon?

                Yes, exactly! As @Pl45m4 already posted above.
                And QCoreApplication is not a QApplication, QApplication inherits QGuiApplication, QGuiApplication inherits QCoreApplication.
                So clearly you cannot use QMenu without gui.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tankist
                  wrote on last edited by
                  #8

                  Thank you. I'm going to return back into GUI with this project.

                  Pl45m4P 1 Reply Last reply
                  0
                  • T tankist has marked this topic as solved on
                  • T tankist

                    Thank you. I'm going to return back into GUI with this project.

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by
                    #9

                    @tankist

                    You could split your whole app into two components. One non GUI or non Qt background/ console program and one Qt GUI part which is responsible for the system tray menu.


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    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