linker command failed with exit code 1 - Mac



  • Hi!

    I am new to Qt and I have a little problem.

    I am trying to create a tic tac toe following a tutorial I found on internet but at some point I get this message :
    <pre><code>ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    </code></pre>

    I have created an interface with the design editor that worked well but when I try to link buttons through the .cpp life it fails.

    Can you help me please?
    It is for a school project and I am quitte in a hustle right now.

    I run on OSX El Capitan with Qt Creator 3.5.0
    Here is my code (classes are in French since I ma french héhé) :

    CLASS FILE

    <code>

    #include "notreclasse.h"
    #include "ui_notreclasse.h"

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

    connect(ui->b1, SIGNAL(clicked()), this, SLOT(f1()) );
    connect(ui->b2, SIGNAL(clicked()), this, SLOT(f2()) );
    connect(ui->b3, SIGNAL(clicked()), this, SLOT(f3()) );
    connect(ui->b4, SIGNAL(clicked()), this, SLOT(f4()) );
    connect(ui->b5, SIGNAL(clicked()), this, SLOT(f5()) );
    connect(ui->b6, SIGNAL(clicked()), this, SLOT(f6()) );
    connect(ui->b7, SIGNAL(clicked()), this, SLOT(f7()) );
    connect(ui->b8, SIGNAL(clicked()), this, SLOT(f8()) );
    
    f_recommencer();
    

    }

    notreClasse::~notreClasse()
    {
    delete ui;
    }

    void notreClasse ::f0()
    {//Fonction executée lorsque l'on clique sur b0
    ui->b0->setText(m_laMarque); //Affiche la marque (ie X ou O)
    ui->b0->setEnabled(false);//désactive le bouton

    if(m_laMarque=="X")//passe de X à O ou de O à X pour le prochain coup
        m_laMarque="O";
    else
        m_laMarque="X";
    

    }

    void notreClasse::f_recommencer()
    {//Cette fonction s'exécute quand on clique sur "Recommencer"
    //Elle remet les boutons dans leur état initial
    ui->b0->setText(""); //ni X ni O
    ui->b0->setEnabled(true); //réactive le bouton si besoin
    ui->b1->setText("");
    ui->b1->setEnabled(true);
    ui->b2->setText("");
    ui->b2->setEnabled(true);
    ui->b3->setText("");
    ui->b3->setEnabled(true);
    ui->b4->setText("");
    ui->b4->setEnabled(true);
    ui->b5->setText("");
    ui->b5->setEnabled(true);
    ui->b6->setText("");
    ui->b6->setEnabled(true);
    ui->b7->setText("");
    ui->b7->setEnabled(true);
    ui->b8->setText("");
    ui->b8->setEnabled(true);
    m_laMarque="X"; //Toutes les parties commencent par X
    }
    </code>

    HEADER FILE

    <code>
    #ifndef NOTRECLASSE_H
    #define NOTRECLASSE_H

    #include <QDialog>

    namespace Ui {
    class notreClasse;
    }

    class notreClasse : public QDialog
    {
    Q_OBJECT

    public slots:
    void f_recommencer();
    void f0();
    void f1();
    void f2();
    void f3();
    void f4();
    void f5();
    void f6();
    void f7();
    void f8();

    public:
    explicit notreClasse(QWidget *parent = 0);
    ~notreClasse();
    QString m_laMarque;

    private:
    Ui::notreClasse *ui;

    };

    #endif // NOTRECLASSE_H
    </code>

    ERROR MESSAGE
    <code>
    Undefined symbols for architecture x86_64:
    "notreClasse::f1()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f2()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f3()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f4()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f5()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f6()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f7()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    "notreClasse::f8()", referenced from:
    notreClasse::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_notreclasse.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [MorpionTuto.app/Contents/MacOS/MorpionTuto] Error 1
    13:42:22: Le processus "/usr/bin/make" s'est terminé avec le code 2.
    Erreur lors de la compilation/déploiement du projet MorpionTuto (kit : Desktop Qt 5.5.0 clang 64bit)
    When executing step "Make"
    </code>


  • Moderators

    You did not define following methods in notreClasse class:

    void f1();
    void f2();
    void f3();
    void f4();
    void f5();
    void f6();
    void f7();
    void f8();
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    To add to @jsulm , when you declare a slot, it's mandatory to implement it even if it doesn't do anything yet.



  • Ho yes!
    Seems obvious now but the error message is not really simple at first.

    How should I do to mark the problem solved?

    Thanks a lot


  • Lifetime Qt Champion

    You have the "Topic Tool" button for that :)


Log in to reply
 

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