Cross Compiling Qt
On of the great aspects of Qt is that it is cross platform. Not only across desktops, but also across devices. The Qt make tool, qmake, can be configured to cross compile for different architectures using different compilers and different settings. How to do all this is reasonably straight forward, but you need to know how to get started.
When you've downloaded and extracted Qt you find yourself facing a configure script with loads of options. Trying to get control of them all can feel overwhelming the first time, so it is good to know what is about to happen.
When you run configure, the build tool, qmake, is built, containing the configuration. This has the implication that you can have multiple qmake binaries for different build targets. QMake is then used to build Qt for the target.
Qt is built from a set of modules, which are separate libraries. This means that you do not have to decide on which modules to use when configuring. Instead, just build everything and make the decision later (using the QT variable in your project file - this is outside the scope of this article). The same applies to plugins (database drivers, image formats, etc).
What is important is if you want to build Qt static or dynamic, if you want to use platform libs for various features (libjpeg, zlib, libpng, etc). Another important, and not so straight forward, configuration option is the compiler to use. This is controlled by what is known as an mkspec - a make specification.
Qt comes with quite a few prepared mkspecs, but it is not uncommon to tweak them a little. They are all kept in the mkspec subdirectory of Qt, with another subdirectory for embedded targets called qws. The spec consists of the files qmake.conf and qplatformdefs.h. The latter is pretty easy to reuse between Linuxes. It defines a number of structures and functions for the underlaying system. The former, qmake.conf, tells qmake how to compile.
Once having found the file, reading it is pretty straight forward. For instance, the QMAKE_CXX variable should list the C++ compiler to use, QMAKE_CXXFLAGS lists the flags to use when invoking the C++ compiler, and so on.
Having all this in place, simply use the -xplatform to specify the spec to use. This argument uses the mkspec directory as base, so to use the $(QTDIR)/mkspec/qws/linux-arm-g++ specify -xplatform qws/linux-arm-g++.
Finally, adding the arguments -nomake demos and -nomake examples can save quite a lot of time.
Johan Thelin is a consultant working with Qt, embedded and free
software. On-line, he is known as e8johan.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- New Products
- RSS Feeds
- This is the easiest tutorial
5 hours 32 min ago - Ahh, the Koolaid.
11 hours 11 min ago - git-annex assistant
17 hours 10 min ago - direct cable connection
17 hours 33 min ago - Agreed on AirDroid. With my
17 hours 43 min ago - I just learned this
17 hours 47 min ago - enterprise
18 hours 17 min ago - not living upto the mobile revolution
21 hours 9 min ago - Deceptive Advertising and
21 hours 44 min ago - Let\'s declare that you have
21 hours 45 min ago



Comments
Unknown option -xplatform
When using Qt Creator under Ubuntu, the option '-xplatform' is unknown (full description can be found at http://www.richelbilderbeek.nl/CppQtCrosscompileToWindowsExample5.htm):
Starting: "/usr/bin/qmake-qt4" /home/richel/qtsdk-2010.04/bin/Projects/Website/CppQtCrosscompileToWindowsExample5/CppQtCrosscompileToWindowsExample5.pro -r -spec linux-g++ CONFIG+=debug -xplatform win32-g++
***Unknown option -xplatform
What am I missing?
Configure, not qmake
Hi, -xplatform is an argument to be given to the configure script of Qt, not to qmake.
Johan Thelin is a consultant working with Qt, embedded and free
software. On-line, he is known as e8johan.
Teaser
Cross-compiling is not as simple as selecting something from a combobox (yet). This IMHO exciting article gives me the feeling that we're nearly there: one needs only a cross-platform compiler (like mingw) and to modify the Qt/qmake project file. Too bad, the article hasn't been detailed enough for me to get it working. I really look forward to a complete example!