March 8, 2011

Miikukka Miikukka
Lab Rat
28 posts

Collect2: ld returned 1 exit status

 

Every times when I try to run something it says that. In Compile Output read

  1. Running build steps for project Testi...
  2. Configuration unchanged, skipping qmake step.
  3. Starting: "C:/QtSDK/mingw/bin/mingw32-make.exe" -w
  4. mingw32-make: Entering directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'
  5.  
  6. C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
  7.  
  8. mingw32-make[1]: Entering directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'
  9.  
  10. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\Testi.exe debug/main.o debug/testi.o debug/moc_testi.o  -L"c:\QtSDK\Simulator\Qt\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib
  11.  
  12. debug/moc_testi.o:C:\Users\Miika\QT sovellukset\Testi-build-desktop/debug/moc_testi.cpp:74: undefined reference to `Testi::on_pushButton_2_clicked()'
  13.  
  14. debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x4c): undefined reference to `QWidget::getDC() const'
  15.  
  16. debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x50): undefined reference to `QWidget::releaseDC(HDC__*) const'
  17.  
  18. debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0xb8): undefined reference to `QWidget::winEvent(tagMSG*, long*)'
  19.  
  20. debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x104): undefined reference to `non-virtual thunk to QWidget::getDC() const'
  21.  
  22. debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x108): undefined reference to `non-virtual thunk to QWidget::releaseDC(HDC__*) const'
  23.  
  24. collect2: ld returned 1 exit status
  25.  
  26. mingw32-make[1]: Leaving directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'
  27.  
  28. mingw32-make[1]: *** [debug\Testi.exe] Error 1
  29.  
  30. mingw32-make: Leaving directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'
  31.  
  32. mingw32-make: *** [debug] Error 2
  33.  
  34. The process "C:/QtSDK/mingw/bin/mingw32-make.exe" exited with code %2.
  35. Error while building project Testi (target: Desktop)
  36. When executing build step 'Make'

I think the problem is in Qt or somewhere because it comes in every project.
What I must do, and what’s wrong?
Thanx and sorry my bad English, I’m Finnish beginner.

 Signature 

There are no stupid questions, only stupid answers.

2 replies

March 8, 2011

Volker Volker
Robot Herder
5428 posts

Did you

  • add Q_OBJECT macro to your QObject derived classes (including QWidget derived classes)
  • declare slots with “public slots:” instead of “public:” (the same for proteced/private)
  • re-run qmake and rebuild you project from scratch

March 9, 2011

Miikukka Miikukka
Lab Rat
28 posts

Yes.
What I must declare?
Yes.

Now I made project again and now it works. WTF

Thank you.

 Signature 

There are no stupid questions, only stupid answers.

 
  ‹‹ Qt c++ : call corresponding view and unload the last view      Using QThread ››

You must log in to post a reply. Not a member yet? Register here!