Symbol(s) not found collect2: ld returned 1 exit status



  • I've searched the forums for this problem but none quite matched what's happening to me. I keep getting these error codes and my compile output is:
    @ld: warning: directory '/usr/local/pgsql/lib' following -L not found
    ld: warning: directory '/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib' following -L not found
    ld: warning: directory '/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib' following -F not found
    Undefined symbols:
    "MainWindow::on_MainWindow_destroyed()", referenced from:
    MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)in moc_mainwindow.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [Gameattempt4-5.app/Contents/MacOS/Gameattempt4-5] Error 1
    make: Leaving directory `~/Gameattempt4-5-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug'
    17:10:38: The process "/usr/bin/make" exited with code 2.
    Error while building project Gameattempt4-5 (target: Desktop)
    When executing build step 'Make'@
    I'm running Mac osx 10.6.8 and when I try to delete the Q_OBJECT like almost every post says to do I get a different error.
    If I need to give anymore information just tell me.



  • Have you tried the most simple solution: Clean All -> Run qmake -> Rebuild?



  • Multiple times. That was the first thing I tried.



  • Show us the code for that class, or if you can't post code describe what are you trying to do, or better try to replicate the behavior in a small test project that you can post here, if you don't find the problem when coding the test code.



  • It's supposed to be a basic text based game.
    These are the two files I think are the problem.
    @#include "userclass.h"
    #include "ui_userclass.h"
    #include <QtGui/QApplication>
    #include <QtGui/QPushButton>
    #include <QtGui/QMessageBox>
    #include <QWidget>

    userclass::userclass(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::userclass)
    {
    ui->setupUi(this);
    }

    userclass::~userclass()
    {
    delete ui;
    }
    void userclass::on_Fighter_clicked()
    {
    QMessageBox *choice=new QMessageBox;
    choice->setText("You chose the Fighter class");
    choice->show();
    this->close();
    }

    void userclass::on_Mage_clicked()
    {
    QMessageBox *choice=new QMessageBox;
    choice->setText("You chose the Mage class");
    choice->show();
    this->close();
    }

    void userclass::on_Knight_clicked()
    {
    QMessageBox *choice=new QMessageBox;
    choice->setText("You chose the Knight class");
    choice->show();
    this->close();
    }
    @
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "userclass.h"
    #include <QtGui/QApplication>
    #include <QtGui/QPushButton>
    #include <QtGui/QMessageBox>
    #include <QWidget>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    void MainWindow::on_pushButton_2_clicked()
    {
    QMessageBox *choice=new QMessageBox;
    choice->setText("You chose to end the game");
    choice->show();
    close();
    }

    void MainWindow::on_pushButton_clicked()
    {
    QMessageBox *choice=new QMessageBox;
    choice->setText("You chose to attack");
    choice->show();
    userclass user;
    user.show();
    this->close();
    }

    void MainWindow::on_actionQuit_triggered()
    {
    this->close();
    }
    @



  • I deleted an unnecessary line and the code started working again. Problem solved.


Log in to reply
 

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