Qt creator - `multiple definition of qMain` error

c++, qt

Solution

The reason for that linking error is because of awkawrd behaivior behalf QT creator. I had in the projectName.pro -

QT       +=    core gui

TARGET = GUI_r
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    main.cpp \                   /////// Double call of main.cpp
    StudentRepository.cpp \
    controller.cpp

HEADERS  += mainwindow.h \
    controller.h \
    StudentRepository.h \
Student.h \
ui_mainwindow.h \        /////Double call of ui_mainwindow.h 
ui_mainwindow.h

FORMS    += mainwindow.ui

Thank you, i hope this post will be usefull to other new users of QTcreator.

Problem

I started to work for my homework using QT creator to make the GUI, but I gt this error and I can't manage to find the reason for it, nor can I understand what it means. I suppose it sees my main function twice but I do not know why... please assist me in fixing this error: error: ``` Makefile.Debug:155: warning: overriding commands for target `debug/main.o' Makefile.Debug:142: warning: ignoring old commands for target `debug/main.o' debug/main.o: In function `Z5qMainiPPc': D:\c++\Labs\GUI_r/../../../info/qt/Desktop/Qt/4.8.1/mingw/include/QtGui/qwidget.h:494: multiple definition of `qMain(int, char**)' debug/main.o:D:\c++\Labs\GUI_r/main.cpp:7: first defined here collect2: ld returned 1 exit status ``` Code: ``` #include <QtGui/QApplication> #include "mainwindow.h" #include "controller.h" #include "StudentRepository.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); StudentRepository *stre = new StudentRepository(); Controller *c = new Controller(stre); MainWindow w(c); w.show(); return a.exec(); } ``` edit: long code removed - not the reason for the error. Check the answere it is useful.

Original source