Table of Content
Qt for Google Native Client
Qt for Native Client allows you to deploy and run Qt applications in supported web browsers. Native Client is currently implemented in the Chrome browser.
For a general introduction to Native Client see the project page [code.google.com] or the 2011 Google IO talk [youtube.com]
Getting Started
To develop C++-based Qt applications targeting native client you need the following:
- A Mac OS X or Gnu/Linux system. Windows is not supported.
- The nacl SDK [code.google.com]. Qt is currently developed against SDK version 15 using newlib toolchain.
- A recent Chromium build [gsdview.appspot.com] You can also use Chrome, but using Chromium makes it easier to stay on a single build. Qt is currently developed against Chromium 15+.
- Source code from qtnativeclient [gitorious.org]
Qt 4 [gitorious.org]. branch “4.8-nacl-sdk-15-newlib”
Qt Creator [gitorious.org] with NaCl target support: Using Qt Creator is not required, but very convenient!
Configuring and building Qt
Qt 4
- x86:
configure -developer-build -nacl -little-endian -release -qt-libjpeg -opengl es2 -no-sql-sqlite
make sub-src
- x86_64:
configure -developer-build -nacl -little-endian -release -qt-libjpeg -opengl es2 -xplatform qws/macx-nacl64-g++ -no-mmx -no-3dnow -no-sse -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2
make sub-src
cd src/plugins/platforms/nacl; make
(SSE disabled in 64-bit builds due to compiler bug)
Qt 5
Patch at: http://codereview.qt-project.org/#change,10675
- configure -nokia-developer -nacl -little-endian -confirm-license -release -qt-libjpeg -opengl es2 -xplatform unsupported/macx-nacl-g++ -static -fast -qconfig nacl -nomake tests -nomake demos -prefix /path/to/qt/build/directory
- make sub-src
Testing Qt
- Run make -k in examples/ and demos/. This will build as many examples as possible.
- Build and run tools/nacldemoserver (/path/to/desktop/qt/bin/qmake -nocache nacldemoserver.pro)
Source Code Overview
Qt
What Works:
- Widgets
- Graphics View
- QThread and QtConcurrent.
- Plastique and CleanLooks styles.
- Just about any “internal” class that does not access the operating system (QList, QString, QRegexp, etc.
Feature disabling is controlled by qconfig-nacl.h and some Q_OS_NACL ifdefs. Qt for NaCl was developed by disabling most features and then re-enabling the ported ones them; there might be additional features in qconfig-nacl.h that can be enabled and work.
Roadmap
- Compile Qt as shared libraries using the sdk-15-glibc toolchain
- OpenGL support
Qt Creator
Qt Creator [gitorious.org] supports targeting the NaCl toolchain, and launching apps using the chrome(ium) browser. The toolchain and browser are found by looking in the PATH, make sure “which i686-nacl-gcc” and “which chrome” returns the correct binaries. Also make sure that Qt Creator actually sees the correct PATH, launching it directly from the terminal usually does the trick.
If everything works correctly then there should be a “NaCl GCC” toolchain as well as a “NaCl” target available.
To test the installation, start by loading and compiling the industry standard Qt porting example: examples/widgets/wiggly
App Deployment
To deploy your app you need the following:
- A web server – any web server will do. Native Client applications are served as static files.
- The nexe(s). x86 and x86_64 covers most (all?) Intel Win/Mac/GNU-Linux systems that runs Chrome.
- A manifest(.nmf) file. The manifest matches CPU architecture with binaries. Start nacldemoserver and browse to examples/widgets/wiggly/wiggly.nmf for a sample.
- Some html and javascript to <embed> the NaCl app and handle loading progress and error events. Look at tools/nacldemoserver for sample code, in particular: naclhtmltemplate.html, qtnaclloader.js, and check_browser.js

