Sqlcipher Compilation for Windows


#1

Regards to all, I have compiled sqlcipher for windows and it works fine, the problem is that I can not use the sqlite3_key () function with QT, it is not found. Should some other configuration be made during the compilation to be able to access it?
Thank you


#2

@maborroto sqlite3_key() is definitely part of SQLCipher. If it is not included in the resulting library then SQLCipher has not been built correctly.


#3

Thanks for your quick response, I already have access to sqlite3_key (), but I get the following error when I try to execute a sql query: SQL logic error or missing database.

Thank you


#4

Hi @maborroto

Can you post a small sample code that shows what you are executing to the point where you receive the error? Do you say that you have access to sqlite3_key because you have defined SQLITE_HAS_CODEC, and/or have you also verified the symbol exists within your compiled library?


#5

When I compile for Windows I put SQLITE_HAS_CODEC, in the result was not found and I typed it in the header file: #define SQLITE_HAS_CODEC = 1, this is the sample code:

bool SQLCipherDatabase::open()
{
const char * name = filename.toUtf8().constData();
const char * myK = key.toUtf8().constData();
if (sqlite3_open(name, &db) == SQLITE_OK) {
qDebug() << "Database Successfully Opened ";
int g =sqlite3_key(db,myK,key.count());
QString errorS(sqlite3_errstr(g));
if(g==SQLITE_OK)
{
qDebug() << "Database Successfully Opened ";
qDebug() << errorS;

return true;
}else
{
qDebug() << “Database ERROR”;
qDebug() << errorS;
return false;
}

}
else
{ Q_ASSERT(false);
sqlite3_close(db);
qDebug () << "Error opening database ";
return false;
}
}


#6

Hello @maborroto - what is the query you are running when the error occurs? Is it happening from the result of sqlite3_key?


#7

Already works, the problem was that I did not run sqlite3_key() before sqlite3_exe().
Thank you very much for your attention.