This question asked hundred times in the net but it seems this programmer nightmare fear. So, I have problem in loading sqlite when the program executed, I tried many thinks and I end with this:
Main.cpp:
#include <QApplication>
//#include <qDebug>
#include "store.h"
#include <QtPlugin>
#include <QCoreApplication>
#include <QSqlDriverPlugin>
#include <qsql_sqlite.h>
#include <qsqldriver.h>
#include <QPluginLoader>
int main(int argc, char **argv)
{
Q_IMPORT_PLUGIN(qsqlite)
Store window;
window.show();
return app.exec();
}
#include <QApplication>
//#include <qDebug>
#include "store.h"
#include <QtPlugin>
#include <QCoreApplication>
#include <QSqlDriverPlugin>
#include <qsql_sqlite.h>
#include <qsqldriver.h>
#include <QPluginLoader>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Q_IMPORT_PLUGIN(qsqlite)
Store window;
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Store.pro:
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += items.h store.h \
sales.h \
workers.h
FORMS += Store.ui
SOURCES += items.cpp main.cpp store.cpp \
sales.cpp \
workers.cpp
LIBS += -L"D:\Qt\4.7.4\plugins\sqldrivers" -lqsqlite
QT += sql
QTPLUGIN += qsqlite
CONFIG += debug static
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += items.h store.h \
sales.h \
workers.h
FORMS += Store.ui
SOURCES += items.cpp main.cpp store.cpp \
sales.cpp \
workers.cpp
LIBS += -L"D:\Qt\4.7.4\plugins\sqldrivers" -lqsqlite
QT += sql
QTPLUGIN += qsqlite
CONFIG += debug static
To copy to clipboard, switch view to plain text mode
When I compile:
g++ -mthreads -Wl,-subsystem,windows -o debug\Store.exe debug/items.o debug/main.o debug/store.o debug/sales.o debug/workers.o debug/moc_store.o -L"d:\Qt\4.7.4\lib" -lmingw32 -lqt
maind -LD:\Qt\4.7.4\plugins\sqldrivers -lqsqlite -LD:/Qt/4.7.4/plugins/sqldrivers -lqsqlited -lQtSqld4 -lQtGuid4 -lQtCored4
debug/main.o: In function `StaticqsqlitePluginInstance':
C:\Documents and Settings\Administrator\Desktop\Store-dev/main.cpp:15: undefined reference to `qt_plugin_instance_qsqlite()'
collect2: ld returned 1 exit status
mingw32-make: *** [debug\Store.exe] Error 1
g++ -mthreads -Wl,-subsystem,windows -o debug\Store.exe debug/items.o debug/main.o debug/store.o debug/sales.o debug/workers.o debug/moc_store.o -L"d:\Qt\4.7.4\lib" -lmingw32 -lqt
maind -LD:\Qt\4.7.4\plugins\sqldrivers -lqsqlite -LD:/Qt/4.7.4/plugins/sqldrivers -lqsqlited -lQtSqld4 -lQtGuid4 -lQtCored4
debug/main.o: In function `StaticqsqlitePluginInstance':
C:\Documents and Settings\Administrator\Desktop\Store-dev/main.cpp:15: undefined reference to `qt_plugin_instance_qsqlite()'
collect2: ld returned 1 exit status
mingw32-make: *** [debug\Store.exe] Error 1
To copy to clipboard, switch view to plain text mode
Bookmarks