Mostafa Talebi
Mostafa Talebi

Reputation: 9173

Visual Studio C++ : Getting Unresolved tokens and unresolved link. What should I do?

I want to use SQLite but I get unresolved-* errors. Here is the summary of what I have done:

Here are three directories:

SourceFiles

-->include
-->src
-->sqlite3

I have added all above three directories to:

Project Properties->C/C++->Additional Include Directories

Then In my main.cpp file, I added the below line:

#include<SQLite/SQliteCpp.h> // this inclusion is correct

But I get errors as follows:

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)

Upvotes: 0

Views: 925

Answers (1)

Amadeus
Amadeus

Reputation: 426

Assuming that you're using the standard sqlite source distribution, there should be a .c or .cpp file inside your sqlite3 directory. That file needs to be included in the project and compiled along with your source. The other possibility is that you may have received the sqlite3 headers with a .lib file -- if that's the case, then you'll need to link the library along with your project.

The reason you're getting those errors is because your header file (sqlite3.h) is referencing functions/symbols/etc. for which there are no definitions. So, that's why you need to either include the .c/.cpp file along with your project (so that you provide the definitions), or else link to a precompiled .lib that basically does the same thing.

Upvotes: 1

Related Questions