sqlite is a sweet little answer to database storage for stand-alone applications. CppSQLite is the best C++ wrapper I found (NOTE: there are many). I didn’t find any quick instructions to get the C code statically linked into a Visual Studio 2005 C++ app, so here they are. At the end, I had all the code wrapped nicely into my application with a size increase of 132kb – and no dependencies! Whoop.
You can just grab the files here if you don’t care about the gory details. Read the included Readme.txt file for quick setup instructions. Everything you need is included, including v3.3.13 of the sqlite source and v3.1 of the CppSQLite files.
Now for the blow-by-blow setup of how to do the static library build yourself. It’s not brain surgery, but it’s good to know – for example, if you want to use a newer version of the source code (in case I get lazy and don’t update this).
- create a new Visual Studio 2005 Win32 console application
- during creation, under advanced options…
- change build target type to “static library”
- uncheck “precompiled header”
- add NO_TCL to preprocessor definitions
- Go here: Project->Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions
- Add NO_TCL to the existing lists of all configurations, to bypass inclusion of TCL support
- change the runtime library (to match whatever project that will be linking to the sqlite library you build)
- Found here: Project->Properties->Configuration Properties->C/C++->Code Generation->Runtime Library
- download the preprocessed source code and add it to the project
- (optional) disable the more neurotic VS8 warnings (even though you can safely ignore them)…
- add _CRT_SECURE_NO_WARNINGS to preprocessor definitions:
- – Go here: Project->Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions
- – Add _CRT_SECURE_NO_WARNINGS to the existing lists of all configurations
- include the resulting static library, along with the CppSQLite wrapper class, in your shiny new project
- read about CppSQLite and write some code!
- disable the following warnings (Project->Properties->C/C++->Advanced->Disable Specific Warnings):
- – 4267;4244;4018;4311;4996;4312;4311
Post a comment if you have any troubles. Have fun!