Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Symbol(s) not found collect2: ld returned 1 exit status
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hubris0010
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

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

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hubris0010
        wrote on last edited by
        #3

        Multiple times. That was the first thing I tried.

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          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.

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hubris0010
            wrote on last edited by
            #5

            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();
            }
            @

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hubris0010
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved