Hi (first post: the reason I started this blog was all the small details re. Qt installation, deployment etc. Had some scattered notes, so I thought why not put them on the web, that way I’ll find them for sure next time they’re needed.)
The really outstanding feature of Qt: you can have a reasonable complex program written in C++ running fine on Windows, then recompile the code in Qt for the Mac or Linux and chances are pretty high it’ll behave the same!
So let’s start by looking on how to install Qt on Windows, Macs or Linux PCs:
- Windows: You will need a fairly modern flavor of Visual Studio installed, or opt for the open source MinGW compiler that you can download and install together with Qt. MinGW is a good choice for portability and cost, you’ll have no problem with Qt or deploying Qt apps on various versions of Windows. For me though, MinGW is less ideal, because most Windows stuff are built using Visual Studio. For example, Qt’s IDE Qt Creator is built with Visual Studio 2013. That means if I want to use MinGW for constructing QtCreator plugins/DLLs, I’ll first have to recompile QtCreator (an half hour exercise) and then switch it to the new MinGW-flavored version.
If you use Visual Studio, Qt currently (version 5.5.1) supports the 2010, 2012 and 2013 versions. If you want a 64-bit Qt, then VS2013 is your only choice. Support for the new Visual Studio 2015 is coming in the next version (5.6).
Installing Qt on Windows XP on Windows Server 2003 can still be done, but when I tested recently, launching Qt Creator results in multiple “The procedure entry point
strnlencould not be located in the dynamic link library msvcrt.dll”; Qt Creator opens after 10 of those errors, less ideal 🙁
Deploying your Qt apps to Windows XP and Windows Server 2003 is also still possible, if you add an extra line to your .pro file.
BTW: Using QtCreator on Windows XP or Windows 2003 server, the start screen can sometimes be only partially refreshed (showing artifacts). Or Qt Creator refuses to start at all. One way to get around that is to disable Qt’s Welcome plugin: select the Help menu, About Plugins, locate the Welcome plugin and deselect the Load tick box for it.
But if Qt Creator doesn’t start at all? Try the same thing using a CMD window:
cd/d C:\Qt\Tools\QtCreator\bin qtcreator -noload Welcome
- Mac: Here you will need a recent download of Xcode and the Command Line Tools for it.
Building apps for your Mac desktop works well, but when deploying your app to other Macs, you need to include Qt’s shared libraries/frameworks in your app bundle. You can do that manually or use a nice utility called
macdeployqtthat will help you, we’ll look at that in a later blog post.
- Linux: I’ve tested Qt on both Ubuntu and Debian, in both of those you’ll first need to download the GCC compiler (the C++ flavored one) and the
sudo apt-get install g++ make
And if linking fails like this:
you need to download the OpenGL utility library as well:
sudo apt-get install libglu1-mesa-dev
Building apps works well, but also on these systems there can be trouble ahead when trying to deploy to other Linux machines without Qt installed. Ubuntu though (not Debian) comes with some Qt DLL/so-files preinstalled so a simple app will run directly. However those DLLs/so-files are usually from an earlier version of Qt, which could work or cause loading errors. We’ll look on what .so files to include later as well.
At this point you should be able to write and run a simple Hello World test program. Next post we’ll look at how to enable C++11 features like auto, range-based for-loops etc.