Thoughts and tips for a daily coding life


Building Qt 4.8 with PostgreSQL support (MSVC)

February 11, 2013 Posted by Antanas , , No comments
Today I was rebuilding my dev environment on to a new Windows 7 VM, so I decided to write up whole process for my own future reference, and maybe it will help someone.

Qt 4 has a buggy temperamental support for Postgre on windows using plugin method, so we are building Postgre support into QSql library. As development IDE, we will be using Qt Creator and MSVC 2010 compiler.

Ok, first step first - download Qt sources from:

Download and install Microsoft Visual C++ 2010 Express from: Run through all the updates to get SP1.

Download PostgreSql (9.1 in our case). If you are going to run database from the same machine, download full installer from: Otherwise download only binaries from: Install or extract into C:\pgsql folder. Add to your PATH variable:

Extract downloaded Qt sources into C:\Qt\[version number] folder (C:\Qt\4.8.4 in our case). Set up environment variables for Qt.
Also add C:\Qt\4.8.4\bin\ to your PATH variable. You can use %QTDIR%\bin\ here, but we are using multiple QT installations, so sticking with full declaration

Open Visual Studio Command Prompt. Add environment variables for Postgre 
SET LIB=C:\pgsql\lib\;%LIB%
SET INCLUDE=C:\pgsql\include\;%INCLUDE%

Switch to Qt directory. Run configure
configure.exe -opensource -confirm-license -debug-and-release -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg -qt-sql-sqlite -qt-sql-psql -qt-sql-odbc -nomake demos -nomake examples
Run nmake
After successful compile, do the cleaning
nmake clean

Download and install Qt Creator (2.6.2 in our case). Sidenote: Qt Creator has jom.exe included ("nmake with multicore support")
If paths were setup properly, default Desktop kit should be already set up.

To set up debugging, we'll have to download and install Debugging Tools for Windows (CDB). Download Windows 7 SDK. In the installer remove all components except debugging tools
Or you can use workaround (if it still will be working) and download debug tools directly from here.
Once installed, open Qt Creator Debugger options, then CDB and click Insert in Symbol paths panel.
You can accept default path or put in your own path to symbol location.

P.S. In the end install Notepad++, ProcessExplorer, 7zip, Dependency Walker


Post a Comment