-
Notifications
You must be signed in to change notification settings - Fork 165
How to compile
Cheng Liang edited this page Apr 8, 2017
·
9 revisions
From this version, we removed Qt private headers, you don't have to edit any code in this project. So compile the plugin is rather simple, just open .pro file using QtCreator and build... Tata!
Don't forget to copy compiled dll (sqlitecipher(d).dll and sqlitecipher(d).lib for Qt4 and sqlitecipher(d).dll for Qt5) to Qt's plugin directory plugins/sqldrivers. Or simply use make install if you could.
- Please notice the debug version has been renamed to sqlitecipher_debug on Mac OS.
- Change QT5_SRC_PATH (or QT4_SRC_PATH) in
sqlitecipher/qt_p.priin order to findqsqlcachedresult_p.h. If you forget, qmake will raise an error. - Try to compile the plugin with sqlitecipher.pro in sqlitecipher.
- Copy compiled dll (
sqlitecipher(d).dllandsqlitecipher(d).libfor Qt4 andsqlitecipher(d).dllfor Qt5) to Qt's plugin directoryplugins/sqldrivers.
- Open
sqlitecipher/qt_p.priand change Qt code tree. The core idea is to findqsqlcachedresult_p.h(usually it is in%QT%/src/sql/kernelfor Qt4 and%QT%/Src/qtbase/src/sql/kernelfor Qt5). - Try to compile the plugin with sqlitecipher.pro in sqlitecipher.
- Copy compiled dll (
sqlitecipher.dllandsqlitecipher.libfor Qt4 andsqlitecipher.dllfor Qt5) to Qt's plugin directoryplugins/sqldrivers.
That's all. The you could test if the plugin is loaded successfully. You could see code in test for how to use it. Just set your password with QSqlDatabase::setPassword() function, that is all you need, e.g.:
QSqlDatabase dbconn = QSqlDatabase::addDatabase("SQLITECIPHER"); dbconn.setPassword("YourPasswort");
- cd SQLite_cipher, try to compile code in this directory. You could use makefile in this directory. After compiling, you will get libsqlite.a or sqlite.lib.
- Copy libsqlite.a or sqlite.lib to sqlitecipher/lib.
- cd sqlitecipher, here you could find qsql_sqlite.cpp. Find the line
sqlite3_key(d->access, "Trucc", 5);in functionbool QSQLiteDriver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &conOpts). Here, string "Trucc" is the password for SQLite and the following 5 should be the length for the password string. You should modify this to your own password. - Compile Qt plugin with sqlitecipher.pro(If you want to use the lastet Qt source code, download Qt code and cd src/plugins/sqldrivers, try to modifed code according to this plugin).
- Finish! You should get sqlitecipher.dll or sqlitecipherd.dll if no any error.