SQLCipher Windows下のコンパイル
10647 ワード
プロジェクトの必要性のため、SQLCipherをコンパイルしてios android windowsの統一を維持する必要があります.
1. vs2013,
2. Activestate Perl, http://www.activestate.com/activeperl
3. openssl, openssl-1.0.1p.tar.gz
, http://blog.csdn.net/herorazor/article/details/47610445
4. Mingw :http://sourceforge.net/projects/mingw/files/
Download mingw-get-setup.exe (86.5 kB)
5. gcc msys mingw , ,
gcc msys tclsh . !
tclsh tclsh command not found,
gcc checking for gcc... no
。。 。。
, msys,
(1) MSYS Base System,
(2) msys-base Mark for installation
(3) installation Apply Changes,
, Apply,
6. , c C:\MinGW
7. , , C:\Perl\bin;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;C:\MinGW\msys\1.0\bin;c:\MinGW\bin
openssl c , ,
8.openssl ibeay32.lib libeay32.dll sqlcipher
C:\MinGW\msys\1.0\msys.bat, sqlcipher ,
cd D:\sqlcipher\sqlcipher-master
./configure --with-crypto-lib=none --disable-tcl CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/c/opensslbuild32/include /d/sqlcipher/sqlcipher-master/libeay32.dll -L/d/sqlcipher/sqlcipher-master/ -static-libgcc" LDFLAGS="-leay32"
,
make clean
make sqlite3.c
make
make dll
sqlite3.c
9. ,sqlite3.h sqlite3.c sqlite3ext.h ssleay32.dll ssleay32.lib libeay32.dll libeay32.lib
vs
SQLITE_HAS_CODEC=1
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_CORE
THREADSAFE
SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
// Test.cpp : 。
//
#include "stdafx.h"
#include "sqlite3.h"
static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
//feed this callback function to handle theresultset returned by the select statement
int i;
for (i = 0; i < argc; i++) { //loop over results
printf("%s = %s
", azColName[i], argv[i] ? argv[i] : "NULL"); //gota love how human radable c is
}
printf("
");
return 0;
} //end callback
int _tmain(int argc, _TCHAR* argv[])
{
sqlite3 *db;
if (sqlite3_open("test.db3", &db) == SQLITE_OK)
{
int n = sqlite3_key(db, "123", 3);
//sqlite3_rekey(db, "", 0);
/*printf("DB file is open
");
if (sqlite3_exec(db, (const char*)"PRAGMA key ='password'", NULL, NULL, NULL) == SQLITE_OK){
printf("Accepted Key
");
};*/
if (sqlite3_exec(db, (const char*)"CREATE TABLE StaffMember (sid varchar(256), name varchar(20),age varchar(20));", NULL, NULL, NULL) == SQLITE_OK) {
printf("Created Table
");
};
/*if (sqlite3_exec(db, (const char*)"INSERT INTO testtable (id,name) values (0,'alice'), (1,'bob'), (2,'charlie');", NULL, NULL, NULL) == SQLITE_OK) {
printf("Gave it some data
");
};
*/
if (sqlite3_exec(db, (const char*)"insert into StaffMember(sid, name, age) values('001', ' ', '17')", NULL, NULL, NULL) == SQLITE_OK)
{
printf("Sent Select
");
}
if (sqlite3_exec(db, (const char*)"SELECT * FROM StaffMember;", callback, NULL, NULL) == SQLITE_OK) {
printf("Sent Select
");
};
/*if (sqlite3_exec(db, (const char*)"delete from StaffMember where sid = '001'", NULL, NULL, NULL) == SQLITE_OK)
{
printf("Sent Select
");
}*/
}
sqlite3_close(db); //close it up properly
return 0;
}
10. http://www.jerryrw.com/howtocompile.php