Emdebian

  • About Emdebian
  • News
  • Toolchain
  • Distributions
  • Development
  • Documentation
  • Support
  • Search

QMake support for Emdebian cross-building

QMake support for Emdebian cross-building


Use this qmake.conf file as a starter when preparing projects to cross-build against Qt. (This is not the same as cross-building Qt itself, this is to support building applications which use Qt.)

Change the value of CROSS_GNU_ARCH to target a different architecture.

To use the file, create a new top-level directory (e.g. armel) and pass that directory to qmake using the -spec argument:

$ qmake -spec armel

MAKEFILE_GENERATOR      = UNIX
TEMPLATE                = app
CONFIG                  += qt warn_on release incremental link_prl
QT                      += core gui
QMAKE_INCREMENTAL_STYLE = sublib

include(/usr/share/qt4/mkspecs/common/unix.conf)
include(/usr/share/qt4/mkspecs/common/g++.conf)
include(/usr/share/qt4/mkspecs/common/linux.conf)

CROSS_GNU_ARCH          = arm-linux-gnueabi
warning("preparing QMake configuration for $$CROSS_GNU_ARCH")
CONFIG += $$CROSS_GNU_ARCH


QMAKE_CC                = $$CROSS_GNU_ARCH-gcc
QMAKE_CXX               = $$CROSS_GNU_ARCH-g++
QMAKE_LINK              = $$CROSS_GNU_ARCH-g++
QMAKE_LINK_SHLIB        = $$CROSS_GNU_ARCH-g++
QMAKE_LINK_C            = $$CROSS_GNU_ARCH-gcc
QMAKE_LINK_C_SHLIB      = $$CROSS_GNU_ARCH-gcc


QMAKE_INCDIR            = /usr/$$CROSS_GNU_ARCH/include/
QMAKE_LIBDIR            = /usr/$$CROSS_GNU_ARCH/lib/
QMAKE_INCDIR_X11        = /usr/$$CROSS_GNU_ARCH/X11R6/include
QMAKE_LIBDIR_X11        = /usr/$$CROSS_GNU_ARCH/X11R6/lib
QMAKE_INCDIR_QT         = /usr/$$CROSS_GNU_ARCH/include/qt4/
QMAKE_LIBDIR_QT         = /usr/$$CROSS_GNU_ARCH/lib/
QMAKE_INCDIR_OPENGL     = /usr/$$CROSS_GNU_ARCH/X11R6/include
QMAKE_LIBDIR_OPENGL     = /usr/$$CROSS_GNU_ARCH/X11R6/lib
QMAKE_AR                = $$CROSS_GNU_ARCH-ar cqs
QMAKE_OBJCOPY           = $$CROSS_GNU_ARCH-objcopy
QMAKE_STRIP             = $$CROSS_GNU_ARCH-strip

load(qt_config)

Also, you can redefine features to have cross-building support, e.g. pkg-config. The default pkg-config support in qmake does not understand cross-building, but this snippet - placed as a file called link_xpkgconfig in a features subdirectory beneath the qmake.conf specified above, can be used to get cross-paths from pkg-config:

for(PKGCONFIG_LIB, $$list($$unique(PKGCONFIG))) {
    PKG_CONFIG_LIBDIR=/usr/$$CROSS_GNU_ARCH/lib/pkgconfig
    QMAKE_CXXFLAGS += $$system(PKG_CONFIG_LIBDIR=$$PKG_CONFIG_LIBDIR pkg-config --cflags $$PKGCONFIG_LIB)
    QMAKE_CFLAGS += $$system(PKG_CONFIG_LIBDIR=$$PKG_CONFIG_LIBDIR pkg-config --cflags $$PKGCONFIG_LIB)
    LIBS += $$system(PKG_CONFIG_LIBDIR=$$PKG_CONFIG_LIBDIR pkg-config --libs $$PKGCONFIG_LIB)
}

Your project file then needs these lines added (alsa and pango are just examples):

linux-g++ {
CONFIG += link_pkgconfig
PKGCONFIG += alsa pango
}

count(CROSS_GNU_ARCH, 1) {
CONFIG += link_xpkgconfig
PKGCONFIG += alsa pango
}

Back to the Emdebian Project homepage.

Home

  • About Emdebian
    • Emdebian & Debian
    • Purpose
    • Flavours
    • Extending Emdebian
    • Localisation support
    • Emdebian Tdebs
  • Cross toolchains
    • Packages
    • Build toolchain
    • Status
    • Search
  • Emdebian Grip
    • Packages
    • Repository Key
    • Installation Guide
    • Ports
  • Emdebian Crush
  • Emdebian Baked
  • Documentation
  • Support
    • Contact Us
    • Mailing List Archives
  • Help Emdebian
    • Developers' Info
    • Subversion
  • News
  • History
    • Slind
    • Stag
    • Emdebsys
  • Links

To report a problem with the web site, e-mail debian-embedded@lists.debian.org.For other contact information, see the Emdebian contact page.

website sources

Last Modified: Tue, Apr 5 03:46:12 UTC 2011
Copyright © 2000-2011 The Embedded Debian Project;
Debian is a registered trademark of Software in the Public Interest, Inc.