I have a simple code:
#include <sqlite3.h>
#include <sqlite.h.in>
#include <cstring>
int main() {
sqlite3 *db = nullptr;
const char *dbName = "en.db";
const char *key = "encryption_key";
int result = sqlite3_open(dbName, &db);
result = sqlite3_key(db, key, strlen(key));
sqlite3_close(db);
return 0;
}
when compile it with:
g++ encrypt.cpp -o encrypt -Isqlcipher/include -Lsqlcipher/libs -ldl -lsqlciphe
I have an error: error: ‘sqlite3_key’ was not declared in this scope
I did verify that libsqlcipher.so has sqlite3_key, by running:
nm libsqlcipher.so | grep sqlite3_key
and get output:
000000000005b47a T sqlite3_key
000000000005b4cd T sqlite3_key_v2
00000000000dd2e0 T sqlite3_keyword_check
00000000000dd2d1 T sqlite3_keyword_count
00000000000dd260 T sqlite3_keyword_name
it looks as it should like look, but still. how do I fix that?
and also have verified the path where it located
Thanks
You need to add
-DSQLITE_HAS_CODEConto the command used to compile forsqlite3_key()to be referenced from the header.