QtCreator and the Visual C++ 2013 compiler

C++As I said in some previous posts, I really enjoy using QtCreator. I also enjoy the lightweight Qt .pro file to handle projects I work on, since I love simple things. A .pro asks me just which files I want to build, and builds them for me, and that’s just it. I dislike, for example, the CMake choice of enforcing the creation of a CMakeLists.txt file; the file looks ugly since I don’t name my files with upper-case letters and I don’t really see the point of the extension.

Unfortunately, since .pro files are used to build Qt projects, you can’t (in theory) use them with a toolchain that you don’t have a Qt library built for. And this makes sense, although it’s frustrating to configure a toolchain and not be able to use a .pro file.

So what should one do if they want to use the the latest update from Microsoft to their support for C++11/14?. Qt doesn’t deliver libraries compiled against it, and, as I explained in an earlier post, the C++ support from Microsoft is a bit confusing. Of course, in this case you have to roll your own Qt library (even if you won’t be using it).

First of all, make sure you have the latest version and the latest Qt sources, in this case 5.2.1. Make sure you have also the sources, and you should have a folder named, for example, “D:\Qt\5.2.1\Src\”. In this folder you will find the QtBase that contains the main Qt sources distribution.

Make sure you start your “visual studio command prompt” that has paths to the proper compiler you want to use. You could also use the 2013 CTP compiler, but the VS 2013 and the 2013 compiler are quite close, and if you plan to not use the qt libraries (like I do), the difference won’t matter.

You will need to use the “configure.exe” executable file to configure the source code and make sure that all the tools are in place. I think that configure searches for the C++ compiler, but I’m not 100% sure. What it definitely doesn’t search for and you need is the Flex/Bison distribution for Windows, which you can find on sourceforge. Unpack the zip package whenever you like, but make sure that you add that to the %Path% environment variable. Also, one last trick, make sure that you copy win_bison.exe as bison.exe as well in the Flex folder, since the compilation will make use of bison.exe (not sure if both). This is probably a bug in Qt’s compilation process.

Use configure with a prefix, for example I used the following line: “configure -prefix D:\Qt\5.2.1\msvc2013-custom -opensource -nomake examples”. Then you can use nmake or jom to build it. Call “nmake install” to copy the relevant sources to the designated prefix.

Since doing this won’t really install everything, I took the liberty of copying the missing folders from the Src folder to my target folder. Only then did QtCreator accept my VS2013 compilation and tool set, and allowed me to use it for building my project with qmake.

Comments are closed.