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. linker command failed with exit code 1 - Mac
Forum Update on Monday, May 27th 2025

linker command failed with exit code 1 - Mac

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 6.2k 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.
  • M Offline
    M Offline
    Matuvu
    wrote on 10 Nov 2015, 12:57 last edited by
    #1

    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>

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Nov 2015, 13:13 last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 10 Nov 2015, 14:09 last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Matuvu
          wrote on 11 Nov 2015, 13:56 last edited by Matuvu 11 Nov 2015, 13:57
          #4

          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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 11 Nov 2015, 16:04 last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            5/5

            11 Nov 2015, 16:04

            • Login

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