I am entirely new to programming with Qt, though I'm quite familiar with C++. I am using Qt 4.2.3 under the GPL version. I configured Dev-C++ to use Qt using this guide:
http://darkhack.googlepages.com/qttutorial
I made a new Dev-C++ project and selected 'Qt', as the settings required are pre-entered in the template file. I am reading a book from which I was able to run a 'Hello World' app easily. The next chapter included creation of a dialog. The files in the project were:
finddialog.h
finddialog.cpp
main.cpp
{Please click on the file names to view the source of each file}. When I tried to compile it though, I got the following error:
multiple definition of `FindDialog::FindDialog(QWidget*)'
first defined here
multiple definition of `FindDialog::FindDialog(QWidget*)'
first defined here
at this line:
|
Source code
|
1
|
FindDialog::FindDialog(QWidget *parent) : QDialog(parent) {
|
I get the 'multiple definition' error two times for each of the member function that in the FindDialog class including the constructor, as mentioned above.
When I tried to run this in Code::Blocks, I still got the same error and it gives a 'multiple declaration' error and a 'first defined here' on the same line no. and even Code::Blocks displays it 2 times.
In addition to that, I get an endless list of linker errors like:
[Linker error] undefined reference to `FindDialog::staticMetaObject'
[Linker error] undefined reference to `vtable for FindDialog'
[Linker error] undefined reference to `vtable for FindDialog'
.....
I am unable to do anything further than this and it is confusing me more and more. Please help.
EDIT:
I re-read the book, and it asks me to include 'finddialog.h' in the main file and not 'finddialog.cpp'. One doing so, I am able to get rid of the 'mutliple definition errors', but the Linker errors are still there. Also, could anyone tell me as to why the book tells me to include 'finddialog.h' when 'finddialog.cpp' already includes it and 'finddialog.cpp' defines the member functions. Also, why does the compiler think that multiple definitions occur even if the cpp file is included only once? Thanks a lot.
Thanks,
rohanprabhu