我想使用 SQLite,但出现 Unresolved -* 错误。以下是我所做工作的总结:
这是三个目录:
源文件
-->include
-->src
-->sqlite3
我已将以上三个目录全部添加到:
Project Properties->C/C++->Additional Include Directories
然后在我的 main.cpp 文件中,我添加了以下行:
#include<SQLite/SQliteCpp.h> // this inclusion is correct
但是我得到如下错误:
error LNK2028: unresolved token (0A0003DF) "public: virtual __thiscall SQLite::Column::~Column(void)" (??1Column@SQLite@@$$FUAE@XZ) referenced in function "public: virtual void * __thiscall SQLite::Column::`vector deleting destructor'(unsigned int)" (??_EColumn@SQLite@@$$FUAEPAXI@Z)
error LNK2028: unresolved token (0A0003EE) "public: __thiscall SQLite::Statement::Ptr::Ptr(class SQLite::Statement::Ptr const &)" (??0Ptr@Statement@SQLite@@$$FQAE@ABV012@@Z) referenced in function "public: __thiscall SQLite::Column::Column(class SQLite::Column const &)" (??0Column@SQLite@@$$FQAE@ABV01@@Z)
error LNK2028: unresolved token (0A0003EF) "public: __thiscall SQLite::Statement::Ptr::~Ptr(void)" (??1Ptr@Statement@SQLite@@$$FQAE@XZ) referenced in function "public: __thiscall SQLite::Column::Column(class SQLite::Column const &)" (??0Column@SQLite@@$$FQAE@ABV01@@Z)
error LNK2019: unresolved external symbol "public: __thiscall SQLite::Statement::Ptr::Ptr(class SQLite::Statement::Ptr const &)" (??0Ptr@Statement@SQLite@@$$FQAE@ABV012@@Z) referenced in function "public: __thiscall SQLite::Column::Column(class SQLite::Column const &)" (??0Column@SQLite@@$$FQAE@ABV01@@Z)
error LNK2019: unresolved external symbol "public: __thiscall SQLite::Statement::Ptr::~Ptr(void)" (??1Ptr@Statement@SQLite@@$$FQAE@XZ) referenced in function "public: __thiscall SQLite::Column::Column(class SQLite::Column const &)" (??0Column@SQLite@@$$FQAE@ABV01@@Z)
最佳答案
假设您使用的是标准的 sqlite 源代码分发版,应该有一个 .c 或 .cpp 文件 在你的 sqlite3 目录中。该文件需要包含在项目中并与您的源代码一起编译。另一种可能性是您可能已经收到带有 .lib 文件的 sqlite3 header ——如果是这种情况,那么您需要将库与您的项目链接起来。
您收到这些错误的原因是因为您的头文件 (sqlite3.h) 正在引用函数/符号/等。没有定义。因此,这就是为什么您需要将 .c/.cpp 文件与您的项目一起包含(以便您提供定义),或者链接到基本上执行相同操作的预编译 .lib。
关于c++ - Visual Studio C++ : Getting Unresolved tokens and unresolved link. 我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27088588/