Saturday, September 24, 2011

Rebuild SQLite driver for Qt in Visual Studio 2010

The default build of SQLite driver in Qt does not have some features such as full text search. You can add the features yourself by rebuilding it. This is how I rebuild using Visual Studio 2010:
  1. Download latest SQLite amalgamation source code from, eg:
  2. Run Visual Studio
  3. Click Qt -> Open Qt Project File (.pro)...
  4. Select  the Qt SQLite project, eg: c:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\
  5. If somehow the project is not opened in Solution Explorer, check the Output window for hints.
  6. In Solution Explorer, open sqlite3.c, right-click on the file tab and select "Open Containing Folder".
  7. Make a backup of that folder.
  8. Extract SQLite source code to that folder, overwriting everything.
  9. Back to Visual Studio.
  10. Right-click sqlite project and click Properties.
  11. Under Configuration, select Debug.
  12. Go to Configuration Properties -> C/C++ -> Preprocessor.
  13. Click "Preprocessor Definitions". Click the down arrow at the far right. Click 
  14. Put whatever SQLite compilation option you want. Here's mine:
  15. Under Configuration, select Release. Visual Studio will prompt you to save. Click "Yes".
  16. Add the same definitions as Debug.
  17. Close any running applications that uses SQLite, such as Qt Assistant.
  18. Rebuild both Debug and Release. Remember to Rebuild, not just Build, Visual Studio may not detect the changes.
  19. If you get error C1033 ("cannot open program database c:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\vc100.pdb"), make sure the folder and files are not read-only.
  20. These files will be created. Check their modified dates to be sure:
    1. C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\debug\qsqlited4.dll
    2. C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\release\qsqlite4.dll
  21. IMPORTANT: qssqlite4.dll and qsqlited4.dll may be created in C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\release (or debug). If this happens, move it to C:\Qt\4.7.4\plugins\sqldrivers\ and overwrite the existing one. When you debug in Visual Studio, the DLL from this folder will be loaded, even though you have copied the SQLite DLL to your project output.

No comments:

Post a Comment