0

I am trying to create a class in Qt but when i do i get the error of

symbol(s) not found for architecture x86_64

and i do not understad why this is happening. The compile output is

Undefined symbols for architecture x86_64:

"MyThread::MyThread()", referenced from:

Login::on_pushButton_clicked() in login.o

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

My code is Pass.h

#ifndef PASS_H
#define PASS_H
#include <QMainWindow>
#include <QSqlQuery>
#include <QThread>
extern int Searching, Account_Type, table;
extern QString query;
extern bool executed;

class Pass
{
public:
    Pass();
};

class MyThread : public QThread
{
public:
    MyThread();
    void run();
};

Pass.cpp

#include "pass.h"
#include <QtCore>
#include <QDebug>
int Searching, Account_Type, table;
QString query;
bool executed;
Pass::Pass()
{
}

void MyThread::run()
{
    qDebug() << "Hello World";
}

and login.cpp where the class is being used

if(tries == 10)
    {
        MyThread mThread;
    }

if i comment out MyThread mThread out the program opens fine. How can i fix this issue.

Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
Root0x
  • 472
  • 1
  • 9
  • 28
  • but i have not used any commands to build the executable all i have done is press the green triangle to build – Root0x Mar 26 '15 at 17:36
  • 1
    Where is your definition of `MyThread::MyThread()`? – Wintermute Mar 26 '15 at 17:42
  • the problem is i hav't ever defined mythread::mythred() i even did i spotlight search on my entire HDD and spotlight could not find anything – Root0x Mar 26 '15 at 18:06
  • the problem is with the line MyThread mThread – Root0x Mar 26 '15 at 18:09
  • 1
    Well, you promised to define one when you declared it in `class MyThread`. If you want to use the default-generated one instead, remove the `MyThread()` declaration from that class, otherwise define one. – Wintermute Mar 26 '15 at 18:43

0 Answers0