Getting 32 bit Qt5, Boost and Visual Studio 2012 to play nice

So, I have recently needed to get Qt5 and boost working with Visual Studio 2012 for 32 bit platforms, and I have to say it was much harder than I was expecting. I’ve written this post for two reasons: To help anyone else that needs to figure out how to do it without spending innumerable hours googling and building the wrong things, and secondly as a brain dump for myself so I have somewhere to reference if I need this again. All of this information is from various corners of the internet and Stack Overflow posts, however hopefully this will save some time. Also it should also be noted this is for windows 8.

Qt

You will need to install DirectX 11 SDK which is part of the windows 8 SDK. So to get that done, download the DirectX 10 SDK. Now, while that is downloading, you will need to remove the Visual C++ 2010 Redistributable Package, otherwise the DirectX installation will fail with an error code “S1023″.

You can easily remove it by opening a command prompt and pasting in…

  • MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
  • MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}

With that out of the way, the installation should now go ahead. Once that is installed reinstall the Visual C++ 2010 Redistributable Package, then the windows 8 sdk.

OK, now we’re ready to move onto getting Qt compiled. First, download and install these:

Note: Once these are installed, ensure perl is before git in your path environment variable to ensure you don’t use an old version of perl that is shipped with git.

Now you need to start up "VS2012 x86 Native Tools Command Prompt". This will ensure when Qt is built, it notices it’s in a x86 environment and build the 32 bit libraries. Once it is open, navigate to where you want Qt to be installed (the rest of this post will assume it’s C:\Qt).

Then run these in order:

  • git clone git://gitorious.org/qt/qt5.git
  • perl ./init-repository –no-webkit
  • configure -developer-build -opensource -mp -nomake tests -debug-and-release -c++11
  • nmake

Now all going well, after a very long time, that will finish building without any errors. Once that is done you will need to add to Additional Include Directories under project properties → Configuration Properties → C/C++ → General and project properties → Configuration Properties → C/C++ → Linker.

Also add QTDIR to the environment variable and set it to C:\Qt\qt5\qtbase.

You will also need to install the visual studio Qt plugin, as this will make your life much easier. Once installed, open up visual studio, and under QT5 select Qt Options and Add the path C:\Qt\qt5\qtbase. You can also include any other needed modules by going to QT5 → QT Project Settings → Qt Modules.

Boost 1.53

Luckily, this is much more straightforward than building Qt. Download boost, extract it somewhere then open a command prompt and navigate to that directory. Once there, run these commands:

  • bootstrap
  • b2 --build-type=complete variant=debug,release

It even tells you the includes to add when it’s done! Thanks Boost!

You may encounter linker errors when using boost::filesystem. If so, you will need to head over to project properties → Configuration Properties → C/C++ → language and set “Tract WChar_t As Built in Type” and make sure it’s set to Yes.

Phew, hopefully that will work for you without giving you the headaches it gave me, or at least will give you a good starting point.

Chris Dempsey