编译 sqlite 合并以获取用户身份验证会引发错误 C2129 和 C1083

标签 c sqlite

我想编译 sqlite 合并来创建一个通过用户身份验证受密码保护的数据库。

我遵循了本教程:https://www.sqlite.org/howtocompile.html 还有 SQLite 的 user_authentication 文档:https://www.sqlite.org/src/doc/trunk/ext/userauth/user-auth.txt

当我尝试在不使用额外的编译时选项“-DSQLITE_USER_AUTHENTICATION”并且不添加其他文档的情况下编译它时,它可以工作。当我尝试编译它时,我在 sqlite.c 处收到错误 C2129,在 userauth.c 处收到错误 C1083

该目录中有以下文件:

  • shell.c
  • sqlite3.c
  • sqlite3.h
  • sqlite3ext.h
  • sqlite3userauth.h
  • userauth.c
cl -DSQLITE_USER_AUTHENTICATION shell.c sqlite3.c userauth.c -Fesqlite3.exe

以下输出:

shell.c
sqlite3.c
sqlite3.c(222878): error C2129: static function 'void sqlite3CryptFunc(sqlite3_context *,int,sqlite3_value **)' declared but not defined
sqlite3.c(16263): note: see declaration of 'sqlite3CryptFunc'
userauth.c
userauth.c(26): fatal error C1083: Cannot open include file: 'sqliteInt.h': No such file or directory
Generating Code...

如果 c 中有类似 C# 的 db.SetPassword("MyPW") 的功能,那就完美了!

最佳答案

I followed [...] the documentation by SQLite for the user_authentication: https://www.sqlite.org/src/doc/trunk/ext/userauth/user-auth.txt

嗯,不,你看起来不像。这些文档说

Activate the user authentication logic by including the ext/userauth/userauth.c source code file in the build and adding the -DSQLITE_USER_AUTHENTICATION compile-time option. The ext/userauth/sqlite3userauth.h header file is available to applications to define the interface.

When using the SQLite amalgamation, it is sufficient to append the ext/userauth/userauth.c source file onto the end of the amalgamation.

您正在使用合并,因此您应该将 userauth.c [的内容]附加到合并中。即,将其内容复制到sqlite3.c的末尾。从您的目录列表和命令行来看,您似乎正在尝试将其构建为单独的源文件,以在最后链接到主文件。这并不等同,特别是,它对 static 函数和变量的作用域的影响有所不同,这正是编译器所提示的。

尚不清楚 -DSQLITE_USER_AUTHENTICATION 是否也应与合并一起使用。对 SQLite 文档的字面阅读表明并非如此,但我倾向于猜测,如果您想启用该功能,实际上无论哪种方式都需要它。

有关缺少 header 的错误有点令人担忧,您可能会再次看到它。如果这样做,只需删除或注释掉相应的 #include 指令就足够了,因为该 header (主要来源之一)中的所有所需声明都应该已包含在合并中.

关于编译 sqlite 合并以获取用户身份验证会引发错误 C2129 和 C1083,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56990702/

相关文章:

c - 显示新文件中的一些字符

c - 什么时候应该使用 mmap 进行文件访问?

java - getWritableDatabase 不起作用

sqlite - 是否可以将自定义元数据添加到 SQLite 列?

c++ - 为什么两个 malloc 之间多了一行 8 字节?

c - 如何从 ListControl(ListView) 中检索数据?

c - C中的"identifier not found"

node.js - Node 的模块函数返回值空/未定义?

android - 无法从 ListView 获取选定的项目文本

sqlite 插入需要很长时间