如何为PowerPC交叉编译Qt X11?

发布于 2024-09-26 21:19:28 字数 494 浏览 7 评论 0原文

我一直在尝试为 PowerPC 交叉编译 Qt X11 一段时间,但一直遇到各种问题。

根据我提供的 Qt 支持的信息,需要做的就是:

  1. 创建一个新的 mkspec
  2. 复制 mkspec/ 中的现有目录 我使用了 linux-g++ 并修改了它。
  3. 修改 qmake.conf 以使用您的工具链、库和包含
  4. 运行以下配置命令:

    ./configure -arch <你的拱门> -xplatform <您的 mkspec> -prefix <您想要安装 Qt 的位置> <其他选项>

  5. 配置完成后,运行make,然后运行make install。您会发现 Qt 安装在您在 -prefix 选项中指定的目录中。

这样做遇到了各种各样的问题。

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 install. You'll find Qt installed in the directory you specified in the -prefix option.

Had all kinds of problems doing this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清醇 2024-10-03 21:19:28

我的解决方案:

  1. mkspecs/linux-g++复制到mkspecs/linux-g++-
  2. 修改mkspecs/linux-g++/qmake.conf代码> 如下例所示。 阅读示例文件中的注释了解具体细节
  3. 我不必修改qplatformdefs.h,尽管您可能会针对您的架构
  4. 使用问题中的选项运行配置脚本连同 makemake install
  5. 现在,您可以针对交叉编译的 Qt X11 来编译代码。 mocuic等已经为你的主机编译好了,所以它们会生成相应的代码。
  6. 要使用交叉编译的 Qt 库运行您的软件,只需将 Qt 安装位置的 /libs 复制到目标 lib 文件夹,或者您可以将其放入其他文件夹中,然后设置 LD_LIBRARY_PATH 以包含 Qt lib 文件夹。

示例 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)

更新:

该解决方案适用于“独立”编译。如果您需要为 Angstrom、OpenEmbedded、Android、OpenWRT 等构建 Qt X11,则必须使用它们各自的构建系统才能正确编译。例如,对于 OpenEmbedded 目标(即 Angstrom),您必须编写 BitBake 配方。

出现此问题是由于需要支持遗留系统。使用嵌入式 Qt 不是一个选择。对于新项目,我强烈建议使用嵌入式 Qt。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文