Undefined symbols for architecture x86_64 Qt

862 Views Asked by At

I have a Qt program that makes use of QtSql, I have included the headers (#include <QtSql/QtSql>) and even ran Run QMake and rebuild however it throws the following linker errors:

Undefined symbols for architecture x86_64:
  "QSqlDatabase::addDatabase(QString const&, QString const&)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::setDatabaseName(QString const&)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::defaultConnection", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::open()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::QSqlDatabase()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::~QSqlDatabase()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::operator=(QSqlDatabase const&)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlError::~QSqlError()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::exec()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::prepare(QString const&)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::bindValue(QString const&, QVariant const&, QFlags<QSql::ParamTypeFlag>)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::QSqlQuery(QString const&, QSqlDatabase)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::~QSqlQuery()", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlDatabase::lastError() const", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::value(int) const", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "QSqlQuery::lastError() const", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
  "operator<<(QDebug, QSqlError const&)", referenced from:
      authcontroller::authenticate(QString const&, QString const&) in authcontroller.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I didn't perform any special steps to set up QtSql nor did I install the SQLite drivers as my understanding is that their already included with the Qt install.

Any ideas? I'm running the latest Qt distribution

Thanks

1

There are 1 best solutions below

1
On

As BaCaRoZzo pointed out, I needed to place QT += sql in the .pro file