Collect2: ld returned 1 exit status



  • Every times when I try to run something it says that. In Compile Output read @Running build steps for project Testi...
    Configuration unchanged, skipping qmake step.
    Starting: "C:/QtSDK/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'

    C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug

    mingw32-make[1]: Entering directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'

    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

    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()'

    debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x4c): undefined reference to `QWidget::getDC() const'

    debug/moc_testi.o:moc_testi.cpp:(.rdata$ZTV5Testi[vtable for Testi]+0x50): undefined reference to `QWidget::releaseDC(HDC_*) const'

    debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0xb8): undefined reference to `QWidget::winEvent(tagMSG*, long*)'

    debug/moc_testi.o:moc_testi.cpp:(.rdata$_ZTV5Testi[vtable for Testi]+0x104): undefined reference to `non-virtual thunk to QWidget::getDC() const'

    debug/moc_testi.o:moc_testi.cpp:(.rdata$ZTV5Testi[vtable for Testi]+0x108): undefined reference to `non-virtual thunk to QWidget::releaseDC(HDC_*) const'

    collect2: ld returned 1 exit status

    mingw32-make[1]: Leaving directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'

    mingw32-make[1]: *** [debug\Testi.exe] Error 1

    mingw32-make: Leaving directory `C:/Users/Miika/QT sovellukset/Testi-build-desktop'

    mingw32-make: *** [debug] Error 2

    The process "C:/QtSDK/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project Testi (target: Desktop)
    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.



  • 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


  • Yes.
    What I must declare?
    Yes.

    Now I made project again and now it works. WTF

    Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.