views:

34

answers:

1

I have been trying to get Qt X11 cross compiled for PowerPC for a while now and kept having various problems.

From the information given my Qt support, all one needs to do is:

  1. Create a new mkspec
    1. Copy an existing directory in mkspec/ I used linux-g++ and modified it.
  2. Modify qmake.conf to use your toolchain, libraries and includes
  3. Run the following configure command:

    ./configure -arch <your arch> -xplatform <your mkspec> -prefix <where you want Qt installed> <other options>

  4. After configure is done, run make then make install. You'll find Qt installed in the directory you specified in the -prefix option.

Had all kinds of problems doing this. My solution in the answers section.

A: 

My solution:

  1. Copy mkspecs/linux-g++ to mkspecs/linux-g++-<my arch>
  2. Modify mkspecs/linux-g++/qmake.conf as in the example below. Read the comments in the example file for specifics
  3. I did not have to modify qplatformdefs.h, though you might for your architecture
  4. Running the configure script with the options in the question worked along with make and make install
  5. Now you can compile your code against your cross-compiled Qt X11. moc, uic, etc. have been compiled for your host, so they will generate code accordingly.
  6. To run your software with your cross-compiled Qt libs, just copy /libs from where you install Qt to your targets lib folder or you can put it into some other folder and set your LD_LIBRARY_PATH to include the Qt lib folder.

Example qmake.conf:

#
# qmake configuration for linux-g++-ppc_74xx
#

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

include(../common/g++.conf)
include(../common/linux.conf)

#
# Modifications to g++.conf
#
# my_arch-g++ is the full executable path of your g++, make sure your PATH
# contains the directory for your toolchain
#
QMAKE_CC         = my_arch-g++
QMAKE_CXX        = my_arch-g++
QMAKE_LINK       = my_arch-g++
QMAKE_LINK_SHLIB = my_arch-g++

#
# I had to provide includes and libraries for packages my toolchain does not
# provide this is mostly X11 and glib stuff.  You'll either have to
# cross-compile it yourself or get it from your distribution
#
QMAKE_CFLAGS     = -I/path/to/your/includes \
                   -L/path/to/your/libs
QMAKE_CXXFLAGS   = $$QMAKE_CFLAGS

#
# Modifications to linux.conf
#
# Same as g++ stuff above
#
QMAKE_AR          = my_arch-ar cqs
QMAKE_OBJCOPY     = my_arch-objcopy
QMAKE_STRIP       = my_arch-strip

#
# I had all kinds of problems linking Qt source with X11 depending on how I
# specified the include paths.  My toolchain provided most X11 functionality
# and I just had to add missing parts in the CXXFLAGS and CFLAGS,
# but specifying exactly where to find X11 includes and libraries specific
# to my toolchain fixed some of the issues I experienced
#
QMAKE_INCDIR_X11  = /path/to/your/toolchain/includes
QMAKE_LIBDIR_X11  = /path/to/your/toolchain/libs

load(qt_config)
Misha M