Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

Building Qt from source with Visual Studio

July 13, 2009
  • Build systems
  • Programming
approximately 2 minutes to read

In case you do UI development, Qt 4.5 and later is now a very interesting alternative since it is licensed under the LGPL. However, if you use Visual Studio, you’ll find that there are no precompiled binaries, so you have to build them on your own.

Qt is a rather large library, and comes with a custom build system – qmake. Building Qt is quite straightforward. I assume you are using Visual Studio 2005 or 2008, with both I had no trouble at all.

Before you start, you should be aware of one important thing: qmake contains all the paths hard-coded in it, so you cannot move your Qt installation. I simply compile it directly at the target location, but it should be possible to compile to a different target by setting the prefix and running an installation. For the remainder of this post, I’ll be not setting the prefix, but installing at the target location. If you had luck with using prefix and installing, please comment, as I couldn’t get this working.

Building

Grab the Windows source package, and extract it to where you want to have Qt. Let’s assume you want to install to Q:\Qt-4.5.2, then simply move the extracted data into that folder (that is, Q:\Qt-4.5.2 should contain the file configure.exe). You cannot move this folder afterwards, so be careful. Side note: You should have several GiB free, as the compilation requires lots of disk space.

The compilation itself is straightforward. Open your Visual Studio command prompt (x86 or x64), optionally run the dx_setenv command from your DirectX SDK (it’s in $DXSDK/Utilities/bin/dx_setenv.cmd), go into your Qt folder, and run configure followed by nmake. To skip the examples and the demos, you should pass -nomake demos -nomake examples – highly recommended, as you don’t need them usually. This will usually take two or more hours (with demos and examples, prepare for several hours!), so far, I didn’t find a way to enable the /MP switch (comment if you know how!). Using configure -fast doesn’t make a noticeable difference, as the build time is not dominated by makefile generation. After the compile finishes, you should run nmake clean which removes temporary files. This is not equivalent to what make clean does with real makefiles! It this case, it really deletes only the *.obj files and leaves all your compiled binaries in place.

A short note on compiling: Before Qt 4.5.2, link-time code generation is enabled by default on Windows. This may be a problem for WebKit, which requires approx. 1.5 GiB of memory for linking (and it takes a long time). So be sure to compile the latest version if you development machine does not have too much memory.

Using from CMake

Well, that’s it. To use Qt for example from CMake, you would point at your newly built qmake in the /bindirectory. All the folder paths are hardcoded in it, so you don’t have to set up anything else.

Update: Added how to skip the demo/example creation, thanks to reader Michael.

Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 21, 2019