# Sqlcipher Compilation for Windows

**URL:** <https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826>\
**Category:** SQLCipher\
**Created:** [November 30, 2016, 10:25pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826 "2016-11-30T22:25:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maborroto](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maborroto](https://discuss.zetetic.net/u/maborroto)\
**Post date:** [November 30, 2016, 10:25pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/1 "2016-11-30T22:25:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [November 30, 2016, 11:10pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/2 "2016-11-30T23:10:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maborroto](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maborroto](https://discuss.zetetic.net/u/maborroto)\
**Post date:** [December 1, 2016, 6:15pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/3 "2016-12-01T18:15:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [December 1, 2016, 10:19pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/4 "2016-12-01T22:19:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![maborroto](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maborroto](https://discuss.zetetic.net/u/maborroto)\
**Post date:** [December 1, 2016, 10:42pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/5 "2016-12-01T22:42:04Z")

</div>

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;  
}  
}

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [December 2, 2016, 6:14pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/6 "2016-12-02T18:14:16Z")

</div>

> [@maborroto](#):
>
> SQL logic error or missing database.

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

---

<div class="post-metadata">

**Author:** ![maborroto](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maborroto](https://discuss.zetetic.net/u/maborroto)\
**Post date:** [December 3, 2016, 3:55pm UTC](https://discuss.zetetic.net/t/sqlcipher-compilation-for-windows/1826/7 "2016-12-03T15:55:16Z")

</div>

Already works, the problem was that I did not run sqlite3\_key() before sqlite3\_exe().  
Thank you very much for your attention.
