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. Error: undefined reference to `qMain(int, char**)'
QtWS25 Last Chance

Error: undefined reference to `qMain(int, char**)'

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 12.0k 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.
  • N Offline
    N Offline
    nimingzhe2008
    wrote on 19 Oct 2012, 12:48 last edited by
    #1

    When I compiled my project,Qt Creator showed this error.I googled it,and many people say it's because of losing main function.But I actually have main function.
    main.cpp
    @#include<QApplication>
    #include"dialog.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    dialog d;
    d.show();

    return app.exec();
    }
    @

    .pro
    @TEMPLATE = app
    TARGET = custombutton_mine
    HEADERS +=
    mybutton.h
    dialog.h

    SOURCES +=
    mybutton.cpp
    dialog.cpp
    main.cpp

    FORMS +=
    dialog.ui@

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JadeN001
      wrote on 29 May 2018, 10:25 last edited by JadeN001
      #2

      I'm getting the same error at compile time. Tried checking entire code line by line , yet can't figure it out.

      J 1 Reply Last reply 29 May 2018, 11:55
      0
      • J JadeN001
        29 May 2018, 10:25

        I'm getting the same error at compile time. Tried checking entire code line by line , yet can't figure it out.

        J Offline
        J Offline
        JonB
        wrote on 29 May 2018, 11:55 last edited by
        #3

        @JadeN001
        How you get the same error "at run time" given that it's a compile-time error message?

        J 1 Reply Last reply 29 May 2018, 12:25
        1
        • J JonB
          29 May 2018, 11:55

          @JadeN001
          How you get the same error "at run time" given that it's a compile-time error message?

          J Offline
          J Offline
          JadeN001
          wrote on 29 May 2018, 12:25 last edited by
          #4

          @JonB sorry its by mistake,yeah i am getting it at compile time

          K 1 Reply Last reply 29 May 2018, 20:38
          0
          • J JadeN001
            29 May 2018, 12:25

            @JonB sorry its by mistake,yeah i am getting it at compile time

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 29 May 2018, 20:38 last edited by
            #5

            What OS, what Qt version, which compiler?
            What do you have in your project file (.pro)?

            Read and abide by the Qt Code of Conduct

            J 1 Reply Last reply 30 May 2018, 05:18
            1
            • K kshegunov
              29 May 2018, 20:38

              What OS, what Qt version, which compiler?
              What do you have in your project file (.pro)?

              J Offline
              J Offline
              JadeN001
              wrote on 30 May 2018, 05:18 last edited by
              #6

              @kshegunov OS:windows
              qt version : Qt 5.10.1 (MSVC 2015, 32 bit).
              i am using sub-project for plugin implementation so my main pro file is containing only
              TEMPLATE = subdirs

              SUBDIRS =
              Server
              plugin

              but i think problem is in my plugin project which is sub project of my main project.

              plugin.pro

              TEMPLATE        = lib
              CONFIG         += plugin
              QT             += widgets
              INCLUDEPATH    += ../mainwindow
              HEADERS += \
                  broadcast_plugin.h
              
              SOURCES += \
                  broadcast_plugin.cpp
              TARGET          = $$qtLibraryTarget(broadcast_plugin)
              DESTDIR         = ../plugins
              
              K 1 Reply Last reply 30 May 2018, 07:18
              0
              • J JadeN001
                30 May 2018, 05:18

                @kshegunov OS:windows
                qt version : Qt 5.10.1 (MSVC 2015, 32 bit).
                i am using sub-project for plugin implementation so my main pro file is containing only
                TEMPLATE = subdirs

                SUBDIRS =
                Server
                plugin

                but i think problem is in my plugin project which is sub project of my main project.

                plugin.pro

                TEMPLATE        = lib
                CONFIG         += plugin
                QT             += widgets
                INCLUDEPATH    += ../mainwindow
                HEADERS += \
                    broadcast_plugin.h
                
                SOURCES += \
                    broadcast_plugin.cpp
                TARGET          = $$qtLibraryTarget(broadcast_plugin)
                DESTDIR         = ../plugins
                
                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 30 May 2018, 07:18 last edited by
                #7

                @JadeN001 said in Error: undefined reference to `qMain(int, char**)':

                but i think problem is in my plugin project which is sub project of my main project.

                You can know - it's a linker error and you should check the build output. Provide the relevant project file for the binary that fails to link.

                Read and abide by the Qt Code of Conduct

                J 1 Reply Last reply 30 May 2018, 10:55
                1
                • K kshegunov
                  30 May 2018, 07:18

                  @JadeN001 said in Error: undefined reference to `qMain(int, char**)':

                  but i think problem is in my plugin project which is sub project of my main project.

                  You can know - it's a linker error and you should check the build output. Provide the relevant project file for the binary that fails to link.

                  J Offline
                  J Offline
                  JadeN001
                  wrote on 30 May 2018, 10:55 last edited by
                  #8

                  @kshegunov yeah thanks..i will go through it.

                  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