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. Why when i build the project at that time why compiler gives error ?
Forum Updated to NodeBB v4.3 + New Features

Why when i build the project at that time why compiler gives error ?

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 6 Posters 2.8k 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.
  • jsulmJ jsulm

    @Qt-embedded-developer said in Why when i build the project at that time why compiler gives error ?:

    i don't have folder template XXX

    Then what is this:

    WARNING: Unable to generate output for: /home/host/HOST/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Makefile [TEMPLATE SUBDIRS]
    

    ?

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #13

    @jsulm @Qt-embedded-developer , @jsulm, @SGaist

    Unable to generate output for: /home/host/HOST/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Makefile [TEMPLATE SUBDIRS]

    TEMPLATE = SUBDIRS

    Setup SUBDIRS template failed in QtCreator from 10 years ago (good Qt answers never fade!):

    It should be TEMPLATE = subdirs, not SUBDIR

    Use TEMPLATE = subdirs instead of TEMPLATE = SUBDIRS, i.e. not upper case letters..

    :)

    Q 1 Reply Last reply
    5
    • JonBJ JonB

      @jsulm @Qt-embedded-developer , @jsulm, @SGaist

      Unable to generate output for: /home/host/HOST/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Makefile [TEMPLATE SUBDIRS]

      TEMPLATE = SUBDIRS

      Setup SUBDIRS template failed in QtCreator from 10 years ago (good Qt answers never fade!):

      It should be TEMPLATE = subdirs, not SUBDIR

      Use TEMPLATE = subdirs instead of TEMPLATE = SUBDIRS, i.e. not upper case letters..

      :)

      Q Offline
      Q Offline
      Qt embedded developer
      wrote on last edited by Qt embedded developer
      #14

      @JonB said in Why when i build the project at that time why compiler gives error ?:

      @jsulm, @SGaist

      when now i am run this complete project i am getting below errors

      On the issue tab it give the below error:

      :-1: error: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function `_start':

      (.text+0x1b):-1: error: undefined reference to `main'

      :-1: error: collect2: error: ld returned 1 exit status

      :-1: error: [Makefile:253: Components] Error 1

      Compiler gives the below errors:

      /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function _start': (.text+0x1b): undefined reference to main'
      collect2: error: ld returned 1 exit status
      make[1]: Leaving directory '/home/host/HOST/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
      make[1]: *** [Makefile:253: Components] Error 1
      make: *** [Makefile:73: sub-Components-make_first] Error 2
      14:54:56: The process "/usr/bin/make" exited with code 2.
      Error while building/deploying project UiDirectoryStructure (kit: Desktop Qt 5.15.2 GCC 64bit)
      When executing step "Make"

      I want to become expert of creating any type of project structure. So can anybody guide how i should start ?

      @jsulm, @SGaist @JonB Thank you for several time contribution in several post of mine

      JonBJ 1 Reply Last reply
      1
      • Q Qt embedded developer

        @JonB said in Why when i build the project at that time why compiler gives error ?:

        @jsulm, @SGaist

        when now i am run this complete project i am getting below errors

        On the issue tab it give the below error:

        :-1: error: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function `_start':

        (.text+0x1b):-1: error: undefined reference to `main'

        :-1: error: collect2: error: ld returned 1 exit status

        :-1: error: [Makefile:253: Components] Error 1

        Compiler gives the below errors:

        /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function _start': (.text+0x1b): undefined reference to main'
        collect2: error: ld returned 1 exit status
        make[1]: Leaving directory '/home/host/HOST/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
        make[1]: *** [Makefile:253: Components] Error 1
        make: *** [Makefile:73: sub-Components-make_first] Error 2
        14:54:56: The process "/usr/bin/make" exited with code 2.
        Error while building/deploying project UiDirectoryStructure (kit: Desktop Qt 5.15.2 GCC 64bit)
        When executing step "Make"

        I want to become expert of creating any type of project structure. So can anybody guide how i should start ?

        @jsulm, @SGaist @JonB Thank you for several time contribution in several post of mine

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #15

        @Qt-embedded-developer
        The system's lib64/crt1.o is the entry point when your program is started. That will call its _start() function, and that in turn will expect to call your program's main(). But the error message says it cannot find any such main(). Which implies your linker command does not include your main program.

        I have never used a subdirs project, sounds like that is not correctly picking up your main program. You could show the complete linker command (Compile Output pane, the last line where it does the linking). Probably needs someone who knows how subdirs project is supposed to work....

        Q 1 Reply Last reply
        0
        • JonBJ JonB

          @Qt-embedded-developer
          The system's lib64/crt1.o is the entry point when your program is started. That will call its _start() function, and that in turn will expect to call your program's main(). But the error message says it cannot find any such main(). Which implies your linker command does not include your main program.

          I have never used a subdirs project, sounds like that is not correctly picking up your main program. You could show the complete linker command (Compile Output pane, the last line where it does the linking). Probably needs someone who knows how subdirs project is supposed to work....

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by Qt embedded developer
          #16

          @JonB Hi My compiler out put is :

          cd Components/ && ( test -e Makefile || /home/host/Qt5.15.2/5.15.2/gcc_64/bin/qmake -o Makefile /home/host/P_host/TWS_11_02_2024/14FEB2024/UiDirectoryStructure/Components/Components.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug ) && /usr/bin/make -f Makefile
          make[1]: Entering directory '/home/host/P_host/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
          g++ -o Components MainApplication.o QmlEngineUtility.o moc_MainApplication.o moc_QmlEngineUtility.o /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Quick.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Widgets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Gui.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5QmlModels.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Qml.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5WebSockets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Network.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread
          /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function _start': (.text+0x1b): undefined reference to main'
          collect2: error: ld returned 1 exit status
          make[1]: Leaving directory '/home/host/P_host/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
          make[1]: *** [Makefile:253: Components] Error 1
          make: *** [Makefile:73: sub-Components-make_first] Error 2
          16:27:37: The process "/usr/bin/make" exited with code 2.
          Error while building/deploying project UiDirectoryStructure (kit: Desktop Qt 5.15.2 GCC 64bit)
          When executing step "Make"
          16:27:37: Elapsed time: 00:00.

          I can able to see that my app folder's main.cpp not included when below command :

          g++ -o Components MainApplication.o QmlEngineUtility.o moc_MainApplication.o moc_QmlEngineUtility.o /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Quick.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Widgets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Gui.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5QmlModels.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Qml.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5WebSockets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Network.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread

          try to build. but i don't know how to allow my main.cpp also. why it automatically not get taken. becuase my main is in main.cpp

          i have created my source code such that the except main.cpp of App project is in Component project. so when i need to write unittest then it help. and as well as i want to link my component connect with app project using static library.

          So what changes i need to do ?

          JonBJ 1 Reply Last reply
          0
          • Q Qt embedded developer

            @JonB Hi My compiler out put is :

            cd Components/ && ( test -e Makefile || /home/host/Qt5.15.2/5.15.2/gcc_64/bin/qmake -o Makefile /home/host/P_host/TWS_11_02_2024/14FEB2024/UiDirectoryStructure/Components/Components.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug ) && /usr/bin/make -f Makefile
            make[1]: Entering directory '/home/host/P_host/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
            g++ -o Components MainApplication.o QmlEngineUtility.o moc_MainApplication.o moc_QmlEngineUtility.o /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Quick.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Widgets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Gui.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5QmlModels.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Qml.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5WebSockets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Network.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread
            /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o: in function _start': (.text+0x1b): undefined reference to main'
            collect2: error: ld returned 1 exit status
            make[1]: Leaving directory '/home/host/P_host/TWS_11_02_2024/14FEB2024/build-UiDirectoryStructure-Desktop_Qt_5_15_2_GCC_64bit-Debug/Components'
            make[1]: *** [Makefile:253: Components] Error 1
            make: *** [Makefile:73: sub-Components-make_first] Error 2
            16:27:37: The process "/usr/bin/make" exited with code 2.
            Error while building/deploying project UiDirectoryStructure (kit: Desktop Qt 5.15.2 GCC 64bit)
            When executing step "Make"
            16:27:37: Elapsed time: 00:00.

            I can able to see that my app folder's main.cpp not included when below command :

            g++ -o Components MainApplication.o QmlEngineUtility.o moc_MainApplication.o moc_QmlEngineUtility.o /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Quick.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Widgets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Gui.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5QmlModels.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Qml.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5WebSockets.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Network.so /home/host/Qt5.15.2/5.15.2/gcc_64/lib/libQt5Core.so -lGL -lpthread

            try to build. but i don't know how to allow my main.cpp also. why it automatically not get taken. becuase my main is in main.cpp

            i have created my source code such that the except main.cpp of App project is in Component project. so when i need to write unittest then it help. and as well as i want to link my component connect with app project using static library.

            So what changes i need to do ?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #17

            @Qt-embedded-developer said in Why when i build the project at that time why compiler gives error ?:

            try to build. but i don't know how to allow my main.cpp also. why it automatically not get taken. becuase my main is in main.cpp

            And that is your problem. Like I said, I have never used a subdirs project. But I imagine that has some "main" project, which has your main.cpp in it. Are you building that top-level, main project, or are you perhaps only building one of the subprojects, which will not have a main?

            Q 1 Reply Last reply
            0
            • JonBJ JonB

              @Qt-embedded-developer said in Why when i build the project at that time why compiler gives error ?:

              try to build. but i don't know how to allow my main.cpp also. why it automatically not get taken. becuase my main is in main.cpp

              And that is your problem. Like I said, I have never used a subdirs project. But I imagine that has some "main" project, which has your main.cpp in it. Are you building that top-level, main project, or are you perhaps only building one of the subprojects, which will not have a main?

              Q Offline
              Q Offline
              Qt embedded developer
              wrote on last edited by Qt embedded developer
              #18

              @JonB I am right clicking on active project name and then i am building it.

              I have shared the main.pro file in main question. where i have added two sub project app and components.

              SGaistS 1 Reply Last reply
              0
              • Q Qt embedded developer

                @JonB I am right clicking on active project name and then i am building it.

                I have shared the main.pro file in main question. where i have added two sub project app and components.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #19

                Share your other .pro files so we can see what is going on.

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

                Q 1 Reply Last reply
                0
                • SGaistS SGaist

                  Share your other .pro files so we can see what is going on.

                  Q Offline
                  Q Offline
                  Qt embedded developer
                  wrote on last edited by
                  #20

                  @SGaist

                  TEMPLATE = subdirs
                  
                  SUBDIRS += \
                      App \
                      Components
                  
                  # Specify dependencies
                  App.depends = Components
                  
                  The first sub dir project App's content is
                  
                      #########################################################################
                      # Define project specific QT settings
                      TEMPLATE = app
                  
                      TARGET = App
                  
                      QT          += qml
                      QT          += quick
                      QT          += core
                      QT          += widgets
                      QT          += websockets
                  
                      CONFIG      += c++17
                  
                  
                      DEFINES += QT_DEPRECATED_WARNINGS
                  
                  
                      DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
                  
                  
                      RESOURCES += \
                          Gui/qml.qrc
                  
                      QML_IMPORT_PATH += $$PWD/Gui/
                  
                      SOURCES += \
                          Main.cpp
                  
                      INCLUDEPATH += $$PWD/../Components
                      INCLUDEPATH += $$PWD/../Components/Utility
                  
                      DEPENDPATH += $$PWD/../Components
                  
                  And the second subdir project content is
                  
                  ```
                  

                  TEMPLATE = app
                  QT += quick
                  QT += core
                  QT += websockets
                  QT += widgets

                  CONFIG      += c++17
                  CONFIG      += staticlib
                  
                  DEFINES += QT_DEPRECATED_WARNINGS
                  
                  
                  DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                  
                  HEADERS += \
                      MainApplication.h \
                      Utility/QmlEngineUtility.h
                  
                  SOURCES += \
                      MainApplication.cpp \
                      Utility/QmlEngineUtility.cpp
                  
                  A C 2 Replies Last reply
                  0
                  • Q Qt embedded developer

                    @SGaist

                    TEMPLATE = subdirs
                    
                    SUBDIRS += \
                        App \
                        Components
                    
                    # Specify dependencies
                    App.depends = Components
                    
                    The first sub dir project App's content is
                    
                        #########################################################################
                        # Define project specific QT settings
                        TEMPLATE = app
                    
                        TARGET = App
                    
                        QT          += qml
                        QT          += quick
                        QT          += core
                        QT          += widgets
                        QT          += websockets
                    
                        CONFIG      += c++17
                    
                    
                        DEFINES += QT_DEPRECATED_WARNINGS
                    
                    
                        DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
                    
                    
                        RESOURCES += \
                            Gui/qml.qrc
                    
                        QML_IMPORT_PATH += $$PWD/Gui/
                    
                        SOURCES += \
                            Main.cpp
                    
                        INCLUDEPATH += $$PWD/../Components
                        INCLUDEPATH += $$PWD/../Components/Utility
                    
                        DEPENDPATH += $$PWD/../Components
                    
                    And the second subdir project content is
                    
                    ```
                    

                    TEMPLATE = app
                    QT += quick
                    QT += core
                    QT += websockets
                    QT += widgets

                    CONFIG      += c++17
                    CONFIG      += staticlib
                    
                    DEFINES += QT_DEPRECATED_WARNINGS
                    
                    
                    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                    
                    HEADERS += \
                        MainApplication.h \
                        Utility/QmlEngineUtility.h
                    
                    SOURCES += \
                        MainApplication.cpp \
                        Utility/QmlEngineUtility.cpp
                    
                    A Offline
                    A Offline
                    Anonymous_Banned275
                    wrote on last edited by Anonymous_Banned275
                    #21

                    @Qt-embedded-developer Can you build / compile each project by itself? Furthermore - are you sure you want TWO app(s) in project ?

                    1 Reply Last reply
                    0
                    • Q Qt embedded developer

                      @SGaist

                      TEMPLATE = subdirs
                      
                      SUBDIRS += \
                          App \
                          Components
                      
                      # Specify dependencies
                      App.depends = Components
                      
                      The first sub dir project App's content is
                      
                          #########################################################################
                          # Define project specific QT settings
                          TEMPLATE = app
                      
                          TARGET = App
                      
                          QT          += qml
                          QT          += quick
                          QT          += core
                          QT          += widgets
                          QT          += websockets
                      
                          CONFIG      += c++17
                      
                      
                          DEFINES += QT_DEPRECATED_WARNINGS
                      
                      
                          DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
                      
                      
                          RESOURCES += \
                              Gui/qml.qrc
                      
                          QML_IMPORT_PATH += $$PWD/Gui/
                      
                          SOURCES += \
                              Main.cpp
                      
                          INCLUDEPATH += $$PWD/../Components
                          INCLUDEPATH += $$PWD/../Components/Utility
                      
                          DEPENDPATH += $$PWD/../Components
                      
                      And the second subdir project content is
                      
                      ```
                      

                      TEMPLATE = app
                      QT += quick
                      QT += core
                      QT += websockets
                      QT += widgets

                      CONFIG      += c++17
                      CONFIG      += staticlib
                      
                      DEFINES += QT_DEPRECATED_WARNINGS
                      
                      
                      DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                      
                      HEADERS += \
                          MainApplication.h \
                          Utility/QmlEngineUtility.h
                      
                      SOURCES += \
                          MainApplication.cpp \
                          Utility/QmlEngineUtility.cpp
                      
                      C Offline
                      C Offline
                      ChrisW67
                      wrote on last edited by
                      #22

                      @Qt-embedded-developer I do not understand your second subproject PRO file. It uses
                      TEMPLATE = app
                      and simultaneously
                      CONFIG += staticlib

                      The CONFIG option staticlib means,

                      The target is a static library (lib only). The proper compiler flags will automatically be added to the project.

                      The target is either an application or a library, not both.

                      1 Reply Last reply
                      3
                      • Q Qt embedded developer has marked this topic as solved on

                      • Login

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