Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking for a way to access SQLite. Is there any? I need it to use under MFC, not .NET.
It's my code:


sqlite3 *db;
char *zErrMsg = 0;
int rc;

rc = sqlite3_open("d:\\1\\test.db",&db);// This line take error!

Error 1 error LNK2019: unresolved external symbol _sqlite3_open referenced in function "public: void __thiscall CTTSPDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTTSPDlg@@QAEXXZ) TTS-PDlg.obj


why was this error happened and how to solve it?
Posted

That's a link error - you need to either compile the sqlite3.c file with your project, or create a .lib file from it and add that to the project dependencies.
 
Share this answer
 
Comments
vahidmn 2-Nov-11 9:47am    
but when i add sqlite3.c to my project and rebuilt it. it gives another error!
Error 1 fatal error C1853: 'Debug\TTS-P.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa) d:\tts\programming\delete1\sqlit\sqlite3.c
Why?
Graham Breach 2-Nov-11 10:02am    
The answer to why is in the error message - you are trying to use a C++ precompiled header from a C file (sqlite3.c)

Either turn off precompiled headers, or create a new project to build a static .lib file from sqlite.c and link to that instead.
vahidmn 2-Nov-11 10:11am    
Thanks, but How can I turn off precompiled headers?
Graham Breach 2-Nov-11 10:17am    
Go to the Project menu, open up the properties dialog, then find Configuration Properties -> C/C++ -> Precompiled Headers and change the "Create/Use ..." option to "Not using precompiled headers".

The better option would be to use a .lib, but that is just slightly more tricky than turning off precompiled headers.
vahidmn 2-Nov-11 10:38am    
Thank you very much
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900