0

I'm trying to use CppSQLite wrapper for SQLite. I downloaded and compiled SQLite here: C:\sqlite\sqlite-autoconf-3310100. Then I downloaded CppSQLite to: C:\sqlite\cppsqlite. I then added these folders to include and library directories in MSVS project. Added the sqlite3.lib file to additional dependencies. As far as I'm aware that's all I have to do. I added #include "CppSQLite3.h" line. I created declared a CppSQLite3DB variable and MSVS says no problem, it know it comes from cppsqlite header. But when I run the project it throws LNK2019 error. Error code is below.

I'm aware of this question that is the same problem as mine but I tried all the answers there except the best answer. None of them worked. And I don't understand what to do in the best answer, I can't comment on it since I don't have enough rep, so I had to create a new question. Can anyone explain to me if that answer will work for me aswell? And if so, what am I supposed to do, can you explain me that answer simply? Thanks in advance!

LNK2019 unresolved external symbol "public: __cdecl CppSQLite3DB::CppSQLite3DB(void)" 
(??0CppSQLite3DB@@QEAA@XZ) referenced in function "bool __cdecl dbop::connectToDatabaseSQLITE(char 
const *)" (?connectToDatabaseSQLITE@dbop@@YA_NPEBD@Z)
One Bad Student
  • 160
  • 2
  • 9
  • Does CppSQLite3 wrapper has a seperate lib other than sqlite3.lib? If so you should add that lib to your project too not only headers – idris Feb 13 '20 at 13:34
  • Yeah, the dude in that question said something about cppsqlite3.lib but i just couldn't find it. Not [here](https://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=6343&display=Mobile) or [here](https://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite). – One Bad Student Feb 13 '20 at 13:40
  • i am adding as answer – idris Feb 13 '20 at 13:43
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/q/12573816/5910058) – Jesper Juhl Feb 13 '20 at 14:31

1 Answers1

0

https://github.com/neosmart/CppSQLite/

Get CppSQLite3.h and CppSQLite3.cpp files from here.

Add to your project.

You dont need to make CppSQLite3 seperate lib.

Adding files to project should be enouh

idris
  • 488
  • 3
  • 6
  • I added the .h file to Header Files, .cpp file to Source Files. Now when I run it I get 33 unresolved externals, all of them in CppSQLite3.obj. :( – One Bad Student Feb 13 '20 at 14:06
  • @OneBadStudent Could you a few of them – idris Feb 13 '20 at 14:13
  • LNK2019 unresolved external symbol sqlite3_close referenced in function "public: void __cdecl CppSQLite3DB::close(void)" (?close@CppSQLite3DB@@QEAAXXZ) – One Bad Student Feb 13 '20 at 14:27
  • LNK2019 unresolved external symbol sqlite3_last_insert_rowid referenced in function "public: __int64 __cdecl CppSQLite3DB::lastRowId(void)const " (?lastRowId@CppSQLite3DB@@QEBA_JXZ) bpv2 C:\Users\ASUS\source\repos\bpv2\bpv2\CppSQLite3.obj 1 – One Bad Student Feb 13 '20 at 14:28
  • sqlite3_last_insert_rowid this is in sqlite3.lib library. if you added it than this error should not happen. – idris Feb 13 '20 at 14:30