开发者

How to cross-compile Qt X11 for PowerPC?

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
  2. Copy an existing directory in mkspec/ I used linux-g++ and modified it.
  3. Modify qmake.conf to use your toolchain, libraries and includes
  4. Run the following configure command:

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

  5. After configure is done, run make then make insta开发者_JAVA技巧ll. You'll find Qt installed in the directory you specified in the -prefix option.

Had all kinds of problems doing this.


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)

UPDATE:

This solution will work for "stand-alone" compilation. If you need to build Qt X11 for Angstrom, OpenEmbedded, Android, OpenWRT, etc. you'll have to use their respective build systems for proper compilation. For example, for OpenEmbedded targets (i.e. Angstrom), you'll have to write a BitBake recipe.

This problem occurred due to a need for supporting legacy systems. Using Embedded Qt was not an option. For new projects, I would strongly recommend the use of Embedded Qt.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜