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:
- Create a new mkspec
- Copy an existing directory in
mkspec/
I used linux-g++ and modified it. - Modify qmake.conf to use your toolchain, libraries and includes
Run the following configure command:
./configure -arch <your arch> -xplatform <your mkspec> -prefix <where you want Qt installed> <other options>
After configure is done, run
make
thenmake 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:
- Copy
mkspecs/linux-g++
tomkspecs/linux-g++-<my arch>
- Modify
mkspecs/linux-g++/qmake.conf
as in the example below. Read the comments in the example file for specifics - I did not have to modify
qplatformdefs.h
, though you might for your architecture - Running the configure script with the options in the question worked along with
make
andmake install
- 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. - To run your software with your cross-compiled Qt libs, just copy
/libs
from where you install Qt to your targetslib
folder or you can put it into some other folder and set your LD_LIBRARY_PATH to include the Qtlib
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.
精彩评论