Deploying Qt on XP and getting “not a valid Win32 application”

By now Windows XP is getting a bit long in the tooth, however Qt still has full support for it. If you’ve installed Qt with Visual Studio (and not the MinGW compiler) and you try deploying your app to a Windows XP or Windows Server 2003 computer, perhaps you’re seeing this error:

is not a valid Win32 application

Too far from the future?

This error will not occur for Qt with Visual Studio 2010, but it will when using Visual Studio 2012 or 2013.

There are basically two ways to fix this, either change the project settings for your app in QtCreator, or you can be more adventurous and binary-patch your app’s .exe file.
And yes, this has to be applied for every app, until XP is gone gone gone…

Read More…

Deploying Qt or how to avoid “could not find or load the Qt platform plugin”

Once you’ve built your first Qt program, have you tried it on another PC?
(Post updated and simplified! Thanks to JKSH on the Qt Project forums.)
Maybe you’ve gotten past .DLL errors, instead you’re stuck on errors like these?

Could not find or load the Qt platform plugin "windows"

If you’ve experienced this, then this blog post is for you :-)

Failed to load platform plugin "xcb"

(Start your app in Terminal to see this)

Failed to load platform plugin "cocoa"

(Same here, Finder only says “App quit unexpectedly”, launch your app in Terminal to see this)

(Want to skip the tourist talk? Jump to the rest of the post.)

If you look at newer languages like Google’s Go, you’ll find an Everything and the Kitchen Sink™-flavored approach to deployment. After you’ve written and debugged a Go program, you issue the go build command. The result is an .EXE file with minimal dependencies on the DLLs, in Windows for example it’s just the usual suspects like KERNEL32.DLL etc. People sometimes complain though, because even a simple ‘Hello World’ app builds into an approx. 2MB .exe file. But deployment problems are more or less nonexistent.

Qt has (as you’ve probably discovered) the complete opposite design. From things like .h files that are designed this way (a humongous file like Windows.h is frowned upon) to the delegation of .DLLs that Qt uses for plugins, platform independency etc. Partially this stems from the early 90′s when Qt was initially designed (in those days deploying a 2MB .exe could constitute a career-limiting move) but probably mostly because it supports so many different architectures and OS’es.

Now, to simplify deployment of Qt apps to other PCs, you can rebuild all or parts of Qt statically. In some environments that makes sense, but I think in general you’re better off following this dynamic library approach.

Read More…

Using C++11 in Qt

Have you also discovered all the new great C++11 stuff? So far I’ve used only the new flavor of auto and some ranged for-loops, but already those I think are excellent improvements.

If you try them in your Qt app however, chances are you will get a compiler error :-(

Read More…

Hello Qt

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!

Read More…