5

hi every one i am working a in qt and qwt but in my program i am getting these error

undefined reference to `vtable for MainWindow' error: collect2: ld returned 1 exit status

i didnt get it what is the meaning of these error can some one explain it as apparently i have no error in my code

thanks

tariq
  • 529
  • 5
  • 19
  • 34

1 Answers1

4

You're not linking to everything you should. You need to run moc on your .cpp files, and add e.g. #include "moc_myfile.cpp" to the end of myfile.cpp

Alternatively, you have declared a virtual function (destructor perhaps) without defining it.

Erik
  • 88,732
  • 13
  • 198
  • 189
  • thanks so much sir one more thing sir i have another same program exactly same but it didnt gave this error and didnt include moc file in my program thanks – tariq Mar 22 '11 at 14:48
  • @randy: You'll need to show the source. The two problems I mentioned are common reasons for this error. If you want more detailed help, provide more details in the question. – Erik Mar 22 '11 at 14:50
  • ok sir thanks the code is a bit lenghty i will try to figure it out my self if i get failed then i will ask . thanks so much for your help – tariq Mar 22 '11 at 14:56
  • 1
    If you're using qmake, add the .h file to the HEADERS (HEADERS += your.h) and rerun qmake. Including the .moc is usually not necessary. – Frank Osterfeld Mar 22 '11 at 15:09