我遇到失败错误:“sqlite3_key”未在此范围内声明

问题描述 投票:0回答:1

我有一个简单的代码:

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

编译时:

g++ 加密.cpp -o 加密-Isqlcipher/include -Lsqlcipher/libs -ldl -lsqlciphe

我有一个错误: 错误:“sqlite3_key”未在此范围内声明

我确实通过运行验证了 libsqlcipher.so 具有 sqlite3_key

nm libsqlcipher.so | grep sqlite3_key

并获得输出:

000000000005b47a T sqlite3_key

000000000005b4cd T sqlite3_key_v2

00000000000dd2e0 T sqlite3_keyword_check

00000000000dd2d1 T sqlite3_keyword_count

00000000000dd260 T sqlite3_keyword_name

它看起来应该是这样,但仍然如此。 我该如何解决这个问题?

并且还验证了它所在的路径

谢谢

sqlite sqlcipher
1个回答
0
投票

您需要将

-DSQLITE_HAS_CODEC
添加到用于编译的命令中,以便从标头中引用
sqlite3_key()

© www.soinside.com 2019 - 2024. All rights reserved.