SQLite database access is now supported using dbExpress in Delphi XE3 and C++Builder XE3. On the SQLite download page you will find a zip file containing the source code for SQLite 3.x (as of this blog post the verison is 220.127.116.11). Also on the download page you will find pre-compiled Windows binaries for the SQLite command line shell application and the SQLite Win32 DLL. In order to use SQLite with Delphi XE3 and C++Builder XE3 64-bit applications, you’ll need to build a 64-bit version of the DLL. You can use C++Builder XE3’s 64-bit compiler to build the 64-bit Windows DLL from the source code. On a 64-bit Windows system (I am using Windows 7), you can put the Win32 SQLite3.dll in the C:\Windows\SysWOW64 folder. After building the 64-bit DLL version, place it in the C:\Windows\System32 folder. On my Mac OS X computer, the libsqlite3.dylib is already included in the /usr/lib folder.
After unpacking the source zip file, the following is the batch file (that I got from our R&D team) that I used to build the 64-bit Windows SQLite3.dll (modify the source path to wherever you put the source code):
set rootdir=^ "C:\Users\embt\Desktop\Demos in progress\CppSQLiteBuildDLL\sqlite-amalgamation-3071502" bcc64^ -tWD^ -L%rootdir%\lib\win64\debug^ -I %rootdir%\include\windows\crtl^ -I %rootdir%\include\windows\sdk^ -D "SQLITE_API=__declspec(dllexport)"^ -D WIN64^ -D NDEBUG^ -D _WINDOWS^ -D _USRDLL^ -D NO_TCL^ -D _CRT_SECURE_NO_DEPRECATE^ -D THREADSAFE=1^ -D TEMP_STORE=1^ -D SQLITE_MAX_EXPR_DEPTH=0^ -D SQLITE_ENABLE_COLUMN_METADATA^ sqlite3.c shell.c pause
A few notes about some of the bcc64 command line options used in the batch file:
- -tWD = target Windows DLL
- -L <value> = library file search path
- -I <value> = include file search path
- -D <name>=<value> = define a symbol name and optional value (used for conditional compilation)
For additional information about SQLite specific compilation options - go to http://www.sqlite.org/compile.html. Please note that the SQLite3 Win32 DLL is built with using the SQLITE_ENABLE_COLUMN_METADATA define. The batch file above also sets this define. Also note that the libsqlite3.dylib that was included in my /usr/lib folder was not built with this option.
Have fun using SQLite3 with your Delphi and C++Builder XE3 applications for Windows (Win32 and Win64) and Mac OS X. I am putting the finishing touches on a short video that shows how to build the 64-bit SQLite3.DLL and also how to build C++Builder XE3 FireMonkey SQLite based applications (including in-memory databases) for Windows and Mac.