SQLite - now on its 3rd major upgrade is the choice. The wrapper file set comes with a sample application that instantiates TSQLiteDatabase & TSQLiteTable classes and demonstrates the SQLite power by creating a table, accessing, and displaying its contents. The bit of a challenge however, is the conversion of the Delphi source code to C++ Builder. However, under normal circumstances, Delphi source code should compile with less or no hassle under C++ Builder. And this blog, by the way, is written to discuss the porting process and not the the features of the wrapper itself.
Porting to Borland C++ Builder 6
The wrapper files come with 3 Pascal source files namely: SQLite3.pas , SQLiteTable3.pas & sqlite3udf.pas and of course the SQL/Database engine file - sqlite3.dll. Because I just need a straightforward database application (ie table), I just used the other two and left out sqlite3udf.pas. The following are the files' simple description:
SQLite3.pas - this is actually the wrapper that insulates the Pascal/Delphi programmer from writing longer DLL access codes. All the mechanisms to access the database engine sqlite3.dll in Pascal/Delphi language are here.
SQLiteTable3.pas- encapsulates the TSQLiteDatabase & TSQLiteTable classes.
To use the wrapper in BCB6 development environment, you need to do the following:
1. Compile the Pascal/Delphi source codes into *.obj & *.hpp intermediate files.
2. Generate static library file from sqlite3.dll by using the Borland Implib utility.
3. Include the resulting files ( total five (5)) in your BCB6 project using the project manager.
4. Explicitly link to the files using #include directive.
Compiling the Pascal/Delphi source codes in BCB6 step by step
1. In the BCB6 IDE, start by creating a new dummy project. Save it in a specific folder.
2.On the same folder, put copies of the wrapper files and sqlite3.dll.
3. In the Project Menu, choose "Add to Project..." then select the Delphi wrapper source codes. Save the project. (Yes, Borland C++ Builder can compile Pascal/Delphi source codes).
4. Open each file in the code window and again, in the Project Menu, choose "Compile Unit". By default, the IDE will generate the *.hpp & *.obj files on the same folder. Now, you need to generate the library file (*.lib) that will be required by the linker later on. The *.lib file actually just contains the symbols being used by the wrapper files but the actual binaries are still inside the sqlite3.dll which will be loaded by the program at runtime. Save and close the dummy project.
5. Using the DOS command prompt go to the folder where you copied the wrapper files and the sqlite3.dll. Remember that this is also the dummy project's folder. You have to use a different name for the resulting library otherwise, the compiler will complain about duplicate symbols. In my case, I used _sqlite3.lib. This is how I generated this file using the implib utility:
Inside the project folder and using the DOS command prompt , execute implib _sqlite3.lib sqlite3.dll.
The static library file _sqlite3.lib will be generated upon hitting the Enter key. Now, all you have to do is to include the five (5) files in your BCB6 Project and lastly, do not forget to #include the SQLiteTable3.hpp in the include section of your *.cpp file. See the other photos for reference.

How files are included in the project using the Project Manager and a code snippet showing the #include directive and instantiating a TSQLiteTable class.
Porting to Turbo C++ Explorer 2006 and beyond
The C++ Builder releases starting year 2006 distinctively made a difference not only in the IDE looks (ie using .NET user interfaces) but also how project input and output files are handled. Depending on the development mode ( Debug or Release), separate folders Release_Build and Debug_Build will be generated by the IDE. The resulting executable file will be on either of these folders. Therefore, do not forget to place a copy of the sqlite3.dll on these folders as the resulting executable will look for this DLL file on those locations. The compilation steps are the same. For some reason, the *.obj files I have generated by compiling the Delphi source inside BCB6 does not link smoothly when I use the same object files inside Turbo C++ Explorer 2006. The right approach therefore is to compile another set of source code into *.obj and *.hpp files using your current version. Happy programming.
Baltazar

