How To Build Qt Creator From Source

From Qt Wiki
Jump to: navigation, search
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.


Building Qt Creator with Qt SDK 1.1.0

This article describes how to build the newest Qt Creator from source. That's an easy and quick way to take a part in developing the Qt Creator tool. These instructions are known to work on Windows for Qt SDK 1.1.0, Qt Creator 2.3.1, and Qt 4.7.4. With appropriate path name changes they should work on OS X and Linux, but I have not tested that yet.

How to build Qt Creator From Source

I decided today that I wanted to chase down a bug in the Qt Creator 2.3.1 Mercurial plugin. "Shouldn't be hard to find," says I to myself, "I'll just re-build a debug version of Qt Creator and step through that part of the code using a debugger." Which was easier said than done, because:

  • Qt Creator 2.3.1 has dependencies on various private interfaces within the Qt library, and
  • The instructions for how to resolve those dependencies turn out to be incomplete.

The official build of Qt Creator is done in an environment where the Qt Library is freshly built. In that environment, all of the private headers are present in the library tree. My goal was to stay within the "as installed" QtSDK environment as much as I could. I also wanted to build things in such a way that I could use the "stock" version of Qt Creator as my debugger, because it has all kinds of useful IDE goodness. Hopefully, my solution will be useful to other people who want to work on Qt Creator, either to fix a bug or to develop a new or improved Qt Creator plugin.

If you want to build Qt Creator without re-building the Qt Library, the recommended procedure is as follows:

  1. Download the source for Qt Creator
  2. Download the source for the Qt Library, so that you have the private headers that Qt Creator needs. I put this in *C:.
  3. Add QT_PRIVATE_HEADERS="C:QtSDKSrcinclude" (using your path to the sources) to the qmake invocation line.
  4. Build.

If QT_PRIVATE_HEADERS is not specified, several components will be omitted from the Qt Creator build because they rely on private header files. If QT_PRIVATE_HEADERS is set, the build on Windows will still fail, because there are dependencies on the qwineventnotifier_p.h header file and some of the qmake project files in the Qt Creator tree haven't been updated to reference QT_PRIVATE_HEADERS in their include lines. The qwineventnotifier_p.h header may be going public soon (bug report).

Ignoring the problem with qwineventnotifier_p.h, the components that get left out when you build this way are not things that you want to leave out when you are debugging Qt Creator. The designer component is one of them, and that one is pretty important. If you are trying to hunt down a problem, you probably want to be using a build that is as close to the "real thing" as you can. So my question was: what was the least change I could make to the build environment provided in the SDK that would let me do a complete build of Qt Creator?

Updating the QtSDK Tree

Here a fairly easy way to update the QtSDK tree to let you build Qt Creator using the SDK:

  1. Install the Qt SDK to *C: (the default)
  2. Download the Qt Creator source code and unpack it to C:. It should work to build it in other locations, but in my case it did not.
  3. Download and unpack the Qt Library source code from the download site. You want this version because it contains the generated include/ directories. The one you get from the package manager does not have these directories. In my case, I unpacked these to *C:
  4. From *c:, copy the private header file directories in include\QtCore, include\QtGui, include\QtDeclarative and include\QtScript to the respective locations under C:.7.4\mingw\include. If you are building using Visual Studio 2008, copy them to the directory tree under C:.7.4\msvc2008\include instead.
  5. The files in the …/private/ directories make reference directly back into the source tree. Copy the C:.7.4\src to C:.7.4\mingw\src (for Visual Studio 2008, copy them to C:.7.4\msvc2008\src). You could probably copy these from *c: instead. I figured that taking them from the QtSources module would reduce the likelihood of "drift" between the sources and the binaries.

Note that these changes are pretty easy to undo. The "official" SDK tree doesn't have source code or private header files down in the Qt Version subdirectories, so they are easy to find and delete by hand.

If you merely want a quick way to make sure that you aren't depending on private interfaces by accident, you can simply rename the src tree you created to _src. The private header files that you copied simply turn around and include things from the src tree. If you include a private header by mistake, moving the src tree will cause a compile failure. This is a nice way to do things, since it's easy to restore.

Caution: Removing the Desktop Qt component (the one you just modified) using the package manager will not remove the extra files. In fact, if you remove and re-install the component, they will still be present!

Hopefully this sort of thing will become unnecessary when the anticipated modularity improvements to Qt Library are implemented.

Building Qt Creator

Now for the fun part.

Using the SDK version of Qt Creator (!), open the file file. I selected the MinGW build environment. I have not tested the build under Visual Studio. Once the project has loaded, you will need to make the following changes:

  • In the Project Build Settings box (both Release and Debug), under Build Steps, select the Details* button for the qmake line.
  • Add QT_PRIVATE_HEADERS="C:QtSDKDesktopQt4.7.4mingwinclude" to the Additional arguments box. The changes you made above have placed all of the necessary private headers in the Qt SDK tree.
  • On Windows: Switch to the Run Settings, and change the Run configuration to app. This may not be necessary on other platforms.

Now re-run qmake and re-build the QtCreator project. Depending on the power of your machine, the build make take as much as an hour.

Hint: If you plan to debug the resulting version of Qt Creator, you may find it helpful to disable Restore last session on startup in the Qt Creator session manager. If you do not disable this, the inferior version of Qt Creator (the one you just built) will happily load up the same Qt Creator project that you have loaded in the superior version of Qt Creator. This is amusing the first time, but both copies of Qt Creator will be attempting to update their "current session" state at the same time, which probably isn't a good thing. If you like, you can create separate sessions named something like Superior Creator and Inferior Creator to help keep things organized.


I'm off to go debug the Mercurial plugin. In the meantime, I hope this "How To" will be useful to somebody.

Building Qt Creator with Qt SDK 1.2

Tested with: Qt SDK 1.2 + Qt Creator 2.6 + Qt 4.8.0 + MSVC 10.0 (Tested on WinXP 32-bit SP3)


  1. Download and Install the QtSDK. Make sure that you have the Development Tools->Qt 4.8.0->Desktop Qt 4.8.0 - MSVC 2010 option checked, if not, you can run the SDKMaintenaceTool and update.
  2. Get the Qt Creator Sources

Checkout the Qt Creator source from gitorious (git clone git://

  1. Get the Qt Sources

Checkout the Qt 4 sources from gitorious (git clone git:// Checked sources during the installation of the Qt SDK ("Miscellaneous -> Qt Sources-> Qt 4.8.0 Sources" should work as well but I do not recommend that, with sources from gitorious you're guaranteed to have most up to date sources.

  1. Download the free version of Visual Studio Express 2010 or Visual C++ Express 2010.


When you have everything installed. We need to set up our toolchain or rather Qt Creator does that for you. After installation of MSVCExpress and restarting system, you should run your Qt Creator, go to Option->Build & Run->Tool Chains, in auto decteted branch you should see the "Microsoft Visual C++ Compiler 10.0". If not add the MSVC tool chain manually.

  • Option 1: Copy Source

Now we need to use our Qt Sources, because normally Qt Creator depends on some private interfaces. To do this we need to go to our qt repository and copy the src directory into QtSDK/Desktop/Qt/4.8.0/msvc2010/ directory. Note that if you checked to install the sources with Qt SDK, files you need should be available in QtSDK/QtSources/4.8.0/src directory.

  • Option 2: Use QT_PRIVATE_HEADERS

set QT_PRIVATE_HEADERS=QtSDK/QtSources/4.8.0/include

The very last last thing we need, is to open the qt-creator project in our Qt Creator, go to Projects tab, and select "Microsoft Visual C++ Compiler 10.0" tool chain.

Comparing to the previous releases of QtSDK (1.1) there was no need for adding the QT_PRIVATE_HEADERS variable into qmake parameters.

Compile & Run

That's the fun part: just press that nice and shiny green play button! Note: I've also set the "Run" option as "app" to se the new QtCreator from source for the first time) That's all! We can build newest QtCreator with a bit older QtCreator. Isn't that great?

I hope you like that quick-and-easy way of building QtCreator.

Note about MinGW compiler: