PDA

View Full Version : Non-existing multiple definition bug



uGin
17th May 2011, 16:29
Hello, $username!

I have one very strange bug with a student project, which sometimes fantastically disappeares but appeares again.

QtCreator/ld says that i have multiply defined function and says something like "first defined here" and points to the strange places like machine code of main.o or (sic!) assembler inlines in some qt core headers.

Sometimes after directory cleaning, it compiles - but next time after the same procedures it points errors again!

Could you compile attachement yourself to see what's really happening?

It is the reason i can't really code what i have to.

jfyi, the project structure:


QT += core gui

TEMPLATE = app

INCLUDEPATH += . \
gui \
logic \
manager

TARGET = Ants
CONFIG += console
CONFIG -= app_bundle

HEADERS = main_window.hpp \
gui/AntWidget.hpp \
gui/IAntGUI.hpp \
gui/IAntGuiImpl.hpp \
logic/IAntLogic.hpp \
logic/IAntLogicImpl.hpp \
manager/AntManager.hpp

SOURCES = main.cpp \
main_window.cpp \
gui/AntWidget.cpp \
gui/IAntGUI.cpp \
gui/IAntGuiImpl.cpp \
logic/IAntLogic.cpp \
logic/IAntLogicImpl.cpp \
#manager/AntManager.cpp

FORMS += MainForm.ui

TIA.

Added after 7 minutes:

All the headers have ifndef-define-endif pattern.

nightghost
17th May 2011, 16:53
Two solutions:

1.) make all methods of AntManager inline or
2.) move the implementation of AntManager to the cpp

for more info whats happinging here, see http://stackoverflow.com/questions/249701/multiple-definitions-due-to-multiple-includes-of-same-header-file