Qt 5.5 Installation for Visual Studio 2015

Update: I wrote this two years ago and don’t remember anything about the process. As such, I cannot provide any support of any kind. I haven’t checked, but I hope Qt Company has made this tutorial obsolete. This page will likely be removed in the near future. The compiled link is broken and will not be fixed.

Note: I do not guarantee any support for this process. I’ve executed this tutorial, as-is, on a completely clean 32 bit Windows 7 install with no issues. If something doesn’t work, you probably didn’t follow the steps exactly.

Let’s get right to business!


Requirements:

  • Qt Framework – Pre-Compiled version here (Broken, and won’t be fixed) (Requires 7-Zip). Compiling from scratch, you’re on your own ūüôā It’s a pain and takes several hours.
  • Microsoft Visual Studio 2015 Installed (Tested on community or greater)
  • Qt Widgets Project Template (Download)

Step 1: Setting up Qt and system PATH variables

  1. Download and extract Qt to the folder of your choice. For this tutorial, I extracted it to the root of the C drive. This is C:\Qt5.5_MSVC
  2. Add the Qt bin¬†folder to your PATH. In this case, it’s C:\Qt5.5_MSVC\msvc2015_32\bin
  3. Create a new system variable called QT55_INCLUDE
    Point this to C:\Qt5.5_MSVC\msvc2015_32\include 
  4. Create another system variable called QT55_LIB
    Point this to C:\Qt5.5_MSVC\msvc2015_32\lib 

 


Step 2: Setting up Visual Studio 2015

  1. Install the Qt Visual Studio extension. Go to Tools > Extensions and Updates and search online for Qt5Package. Install this extension.
  2. Import the Qt Widgets Project Template you downloaded above. To do this in Windows 7, place the zip file in C:\Users\<AccountName>\Documents\Visual Studio 2015\Templates\ProjectTemplates
  3. To test that this worked, try to create a new project. You should see this:
    qtTutorial1

If you’ll notice, the Qt5Package¬†extension created Qt5 Projects templates. By all means, try using these first. I’ve tried to get it to work, but I only get an error:¬†Cannot instantiate QtProjectEngine object!

Obviously, if you can get the Qt Project wizard to work it’s preferable, but I included a basic widgets project template because I could never figure out how to make it work.


Step 3: Running the Qt Application

  1. Create a new project based on the template provided. If¬†you try to build, you’ll get an error because no Qt version is specified.
  2. Go to QT5 > Qt Options > Add. From this menu, click the “…” button and point it to¬†C:\Qt5.5_MSVC\msvc2015_32
  3. The name field should be automatically populated. You can change this if you wish. After accepting, you should see this:
    qtTutorial2
  4. Right click on the project and select Qt Project Settings. Under Version select the Qt version you just created.
  5. Open the¬†qt.conf file. Point the “Plugins” variable to the plugins directory. In my case, it looks like this:

qtTutorial3
IMPORTANT: Make sure you either a) Use forward slashes or b) Escape backslashes.

 


Step 4: Run the project!

qtTutorial4

 


Things to keep in mind

  1. Deployment: This configuration dynamically links to the Qt DLLs in the Qt bin folder so you don’t have to include them in each of your project’s folders.
  2. If you are getting console spam about symbols not being loaded, refer to this MSDN article.
  3. The qt.conf is not copied over on a release build. This is intentional.
  4. The project template uses the system environment variables set in step 1. If you’re having linker errors, you either used a different name or you didn’t set the variable to the correct path.

If this tutorial saved you many hours, or if anything else on this site is useful to you, consider donating!

8 Comments on “Qt 5.5 Installation for Visual Studio 2015
  1. Hi,

    Thank you so much for providing the pre-compiled version for visual studio 2015 !

    I have included in my project and have issues with gl2.h include files that provoque duplicated declarations…
    Looking around the web it seems that the solution should be built with the option -opengl desktop
    (http://stackoverflow.com/questions/17123100/glew-and-qt5-redefinition-of-headers)

    Would you be able to provide the pre-compiled version with this option as well?

    Thanks a bunch !
    Vincent

    • Hi Vincent. That’s a good suggestion. It’s been a while since I’ve built Qt. If it’s only a compiler flag (which seems like the case) I’ll try to take a look either tonight or tomorrow. Since the builds take a very long time I can’t promise a quick turnaround. ūüôā

      If you need it ASAP, I’d suggest attempting your own build. I’m assuming still no precompiled binaries from QtCompany?

  2. Hey Christopher !
    Thanks for your reply.

    Nop, no precompiled binaries for VS2015 from Qt…
    Alright, I’m going to give it a shot !

    I’ve used the script in the link you provided (with a few modifications: removed all the UIC stuff, added -platform win32-msvc2015, added -opengl desktop, added -skip qtwebkit, added -skip qtwebchannel) and, sure enough, there is an issue with nmake.. I get these errors:
    NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.

    Do you by any chance remember how you fixed it ?
    The UIC stuff seemed to be needed only for webkit, do you know anything about that?

    Thanks a bunch!
    I really need to get this working…

    Cheers
    Vincent

    • Vaguely!

      This is all from memory six months ago, so take it as you will. I think it’s only nmake not being called from the right directory. Whatever it was, it was something stupidly simple like that.

      I actually fixed and modified the script withwith the intention of re-sharing it, but I apparently deleted it alongside the source files.

  3. So when I go to use the your widgets and and I try and compile it I get this ugly looking error “cmd.exe” has exited code 3 and then under the out put log it states moc’ing cannot find the path any ideas how to fix this?

  4. Hi Christopher,

    Sorry wenn ich dich auf deutsch scheibe.

    Danke f√ľr das Tutorial. Es ist echt sehr Hilfsreich.
    Bei dieses Tutorial ist mir nicht klar wie du bei der Step3 ” Running the Qt Application” punkt 5 gekommen bist.
    Wie kann ich die qt.conf erstellen bzw. Wie hast du diese erstellt?
    Danke in Voraus

Leave a Reply

Your email address will not be published. Required fields are marked *