PDA

View Full Version : QSQLCIPHER driver not loaded



jpmgr
14th February 2015, 10:00
I have built QSQLCIPHER drivers. It produced 4 files.i.e. qsqlcipher.dll(761kb), qsqlcipherd.dll(3619kb),qsqlcipher.a(3kb), qsqlcipherd.a(3kb). I am using Qt 5.3.0 on windows. I put the two qsqlcipher dll files in C:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers folder. If I try to view available database drivers using the following code QSQLCIPHER driver is not shown up.


qDebug()<<QSqlDatabase::drivers();

ChrisW67
14th February 2015, 20:33
If you have dynamically linked against the OpenSSL library when building SqlCipher then you will need to ensure the required OpenSSL Dlls are on the system path or in the same folder as the plugin.

jpmgr
15th February 2015, 05:31
Let me explain the steps that I followed:(sqlcipher is in c:\sqlcipher)

1)./configure --with-crypto-lib=none --disable-tcl CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/c/openssl-win32/include /c/sqlcipher/libeay32.dll -L/c/sqlcipher/ " LDFLAGS="-leay32"

2) make clean
3) make sqlite3.c
4) make
5) make dll

sqlcipher.pro file


TARGET = qsqlcipher

HEADERS = C:/Qt/Qt5.3.0/5.3/Src/qtbase/src/sql/drivers/sqlite/qsql_sqlite_p.h
SOURCES = smain.cpp \
C:/Qt/Qt5.3.0/5.3/Src/qtbase/src/sql/drivers/sqlite/qsql_sqlite.cpp

!system-sqlite:!contains( LIBS, .*sqlite3.* ) {
CONFIG(release, debug|release):DEFINES *= NDEBUG
DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_HAS_CODEC
INCLUDEPATH += include
INCLUDEPATH +=c:/sqlcipher
LIBS += -Ic:/sqlcipher -Ic:/OpenSSL-Win32/include c:/sqlcipher/libsqlite3.dll c:/openssl-win32/libeay32.dll

} else {
LIBS *= $$QT_LFLAGS_SQLITE
QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE
}

include(../qsqldriverbase.pri)


smain.cpp file:


#include <qsqldriverplugin.h>
#include <qstringlist.h>
#include "../../../qtbase/src/sql/drivers/sqlite/qsql_sqlite_p.h"

QT_BEGIN_NAMESPACE

class QSQLCipherDriverPlugin : public QSqlDriverPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(
IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "sqlcipher.json")

public:
QSQLCipherDriverPlugin();

QSqlDriver *create(const QString&);
QStringList keys() const;
};

QSQLCipherDriverPlugin::QSQLCipherDriverPlugin()
: QSqlDriverPlugin()
{
}


QSqlDriver *QSQLCipherDriverPlugin::create(const QString& name)
{
if (name == QLatin1String("QSQLCIPHER"))
{
QSQLiteDriver *driver = new QSQLiteDriver();
return driver;
}
return 0;
}


QStringList QSQLCipherDriverPlugin::keys() const
{
QStringList l;

l << QLatin1String("QSQLCIPHER");
return l;
}


QT_END_NAMESPACE

#include "smain.moc"


What am I missing ?

ChrisW67
15th February 2015, 09:59
1. You have built SqlCipher to dynamically link with the OpenSSL library libeay32. This DLL needs to be available at run time for the plugin to be able to load.
2. Your configure command is a bit of a mess but probably not the cause of a failure to load. I would have expected something like:


./configure --disable-tcl \
CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/c/openssl-win32/include" \
LDFLAGS="-L/c/openssl-win32/lib -leay32"