LNK 2019: unresolved external symbol "__declspec(dllimport) public: void__thiscall



  • Error:
    http://puu.sh/3m6Qr.png

    my files

    .pro
    @#-------------------------------------------------

    Project created by QtCreator 2013-06-22T00:33:21

    #-------------------------------------------------

    QT += core gui
    QT += widgets
    QT += network

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = guangdong
    TEMPLATE = app

    SOURCES += main.cpp
    login.cpp

    HEADERS += login.h

    FORMS += login.ui
    @

    login.cpp
    @#include "login.h"
    #include "ui_login.h"
    #include <QtSql/QSql>
    #include <QtSql/QSqlDatabase>
    #include <QDebug>
    #include <Query.h>
    #include <QString>
    #include <QtSql/QSqlQuery>
    #include <QtNetwork/QNetworkInterface>

    login::login(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::login)
    {
    ui->setupUi(this);
    blah();
    }

    login::~login()
    {
    delete ui;
    }
    void login::blah()
    {
    // QSqlQuery query;
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("blah");
    db.setDatabaseName("blah");
    db.setUserName("blah");
    db.setPassword("blah");
    bool ok = db.open();

    if ( ok ) {
        ui->label->setText("databaseopen");
        db.close();
    }
    else
        ui->label->setText("Error opening");
    

    }
    @

    main.cpp
    @#include "login.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    login w;
    w.show();

    return a.exec(&#41;;
    

    }
    @

    I'm not an expert programmer at all, please answer me like i dont know anything, thank you!

    Edit: I am using Qt 5.0.2 and msvc2010 compiler


  • Moderators

    Try adding Qt += sql into your .pro file.


Log in to reply
 

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