Skip to content

Building 64-bit Windows SQLite DLL using C++Builder XE3 64-bit compiler

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 3.7.15.2).  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.

{ 2 } Comments

  1. A. Bouchez | March 23, 2013 at 1:17 am | Permalink

    You can find our own 3.7.16 version of the SQlite3 external library, to be used in 64 bit mode, and compiled with the above line code (including FTS3/FTS4) to be downloaded from http://synopse.info/files/SQLite3-64.7z

    This is the version we use when our Open Source mORMot framework targets Win64, using Delphi XE2/XE3.

    Hope it helps.

    Thanks for the input, David!

  2. John Jacobson | April 30, 2013 at 6:36 pm | Permalink

    Can I build 64-bit object files in C++ Builder XE4 and link them directly into a 64-bit Delphi XE4 project, rather than having them be a separate DLL?

{ 1 } Trackback

  1. Delphi SQlite mit 64 Bit? - Delphi-PRAXiS | February 4, 2014 at 4:40 am | Permalink

    [...] AW: SQlite mit 64 Bit?   Heute, 13:39 Offiziell irgendwie nicht. Aber siehe hier: http://blogs.embarcadero.com/davidi/2013/01/25/42392 [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 4 access attempts in the last 7 days.

Close