Results 1 to 3 of 3

Thread: error connecting to MySQL

  1. #1
    Join Date
    Apr 2015
    Location
    My home is in beautiful North Carolina.
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default error connecting to MySQL

    I've installed QT 5.4.1 and working in QT Creator 3.3.2.

    I'm getting this error code:
    C:\www\QtGui\testMysqlConnection\main.cpp:28: error: undefined reference to `_imp___ZN12QSqlDatabaseC1Ev'

    line 28 has these lines of code (qDebug() << "Connected!";
    QSqlQuery query;
    query.exec("SELECT fname FROM client");
    )
    The includes:
    #include <QCoreApplication>
    #include <QtSql/QSql>
    #include <QtSql/QSqlDatabase>
    #include <QtSql/QSqlDriver>
    #include <QtSql/QSqlQuery>
    #include <QDebug>

    Thanks for your help.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: error connecting to MySQL

    That is a linker error, not an error connecting to MySql.

    Have you added
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    To your pro file and rerun qmake?
    http://doc.qt.io/qt-5/qtsql-index.html

  3. #3
    Join Date
    Apr 2015
    Location
    My home is in beautiful North Carolina.
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error connecting to MySQL

    Thanks for the reply Chris, my apologizes for the late response.
    I have solved the mysql connecting. You were right I did not have QT += sql in pro among other things.
    Thanks again.
    I'm also now using SQLite database and for my purposes I like better.

Similar Threads

  1. Problem with connecting to MySql using SSL
    By moosa in forum Qt Programming
    Replies: 2
    Last Post: 25th July 2011, 01:49
  2. connecting MySQL remotely
    By rickym in forum Qt Programming
    Replies: 5
    Last Post: 25th March 2007, 09:55
  3. Crash while connecting to MySQL
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 13:05
  4. connecting to MySQL through it's API
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 20
    Last Post: 30th May 2006, 23:22
  5. Error connecting to MySQL
    By probine in forum Qt Programming
    Replies: 20
    Last Post: 23rd February 2006, 23:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.