[UPDATE2]qt 5.7似乎在windows环境下存在交叉编译问题(cygwin/mingw(。qt5.5可以相对容易地进行交叉编译。
我正在使用我在cygwin上使用crosstol ng生成的工具链,在树莓皮上将qt 5.7.0交叉编译到armv7 linux目标。
主持人:cygwin工具链:armv7-rpi2-linux-gnueabihf(通过交叉工具ng生成(目标:armv7 linux
我下载并提取了qt 5.7.0 tarball,并从cygwin shell中的cygwin目录结构下提取了它(即,我没有使用winzip/7zip来提取文件(。
configure命令:
~/qtpi]$ ./configure -prefix /cygdrive/c/qt5pi -debug-and-release -no-accessibility -device
linux-rpi3-g++ -opensource -confirm-license -make libs -platform cygwin-g++
-device-option CROSS_COMPILE=/cygdrive/c/cygwin64/home/admin/x-tools/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-
-sysroot /cygdrive/c/cygwin64/home/admin/x-tools/armv7-rpi2-linux-gnueabihf/armv7-rpi2-linux-gnueabihf/sysroot -v
configure完成如下。。。
...
...
xkbcommon-x11........... no
xkbcommon-evdev......... no
zlib ................... yes (bundled copy)
NOTE: Qt is using double for qreal on this system. This is binary
incompatible against Qt 5.1. Configure with '-qreal float' to create a build
that is binary compatible with 5.1.
Qt is now configured for building. Just run 'make'. Once everything is
built, you must run 'make install'. Qt will be installed into
/cygdrive/c/qt5pi
Prior to reconfiguration, make sure you remove any leftovers from the
previous build.
此时运行make会出现以下错误:
~/qtpi]$ make
cd qtbase/ && ( test -e Makefile || /home/admin/qtpi/qtbase/bin/qmake /home/admin/qtpi/qtbase/qtbase.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && /usr/bin/make -f Makefile
make[1]: Entering directory '/home/admin/qtpi/qtbase'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make[1]: *** [Makefile:43: sub-src-make_first] Error 1
make[1]: Leaving directory '/home/admin/qtpi/qtbase'
make: *** [Makefile:78: module-qtbase-make_first] Error 2
我在这里被困了半天。AFAIK这似乎与dos unix行结尾或mingw shell无关(我也通过mingw得到了同样的错误(
[UPDATE1]这里是/home/admin/qtpi/qtbase/Makefile的前200多行供参考。
#############################################################################
# Makefile for building: qtbase
# Generated by qmake (3.0) (Qt 5.7.0)
# Project: qtbase.pro
# Template: subdirs
# Command: /home/admin/qtpi/qtbase/bin/qmake -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile qtbase.pro
#############################################################################
MAKEFILE = Makefile
first: make_first
QMAKE = /home/admin/qtpi/qtbase/bin/qmake
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
COPY = copy /y
COPY_FILE = copy /y
COPY_DIR = xcopy /s /q /y /i
INSTALL_FILE = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR = xcopy /s /q /y /i
DEL_FILE = del
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = move
SUBTARGETS =
sub-src
sub-examples
sub-tests
sub-qmake-qmake-aux-pro
sub-src-qmake_all: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
cd src/ && $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && $(MAKE) -f Makefile qmake_all
sub-src: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-src-make_first: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-src-all: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile all
sub-src-clean: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile clean
sub-src-distclean: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile distclean
sub-src-install_subtargets: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile install
sub-src-uninstall_subtargets: FORCE
@if not exist src/ mkdir src/ & if not exist src/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd src/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/src/src.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile uninstall
sub-examples-qmake_all: sub-src-qmake_all FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
cd examples/ && $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && $(MAKE) -f Makefile qmake_all
sub-examples: sub-src FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-examples-make_first: sub-src-make_first FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-examples-all: sub-src-all FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile all
sub-examples-clean: sub-src-clean FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile clean
sub-examples-distclean: sub-src-distclean FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile distclean
sub-examples-install_subtargets: sub-src-install_subtargets FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile install
sub-examples-uninstall_subtargets: sub-src-uninstall_subtargets FORCE
@if not exist examples/ mkdir examples/ & if not exist examples/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd examples/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/examples/examples.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile uninstall
sub-tests-qmake_all: sub-src-qmake_all FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
cd tests/ && $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && $(MAKE) -f Makefile qmake_all
sub-tests: sub-src FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-tests-make_first: sub-src-make_first FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile
sub-tests-all: sub-src-all FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile all
sub-tests-clean: sub-src-clean FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile clean
sub-tests-distclean: sub-src-distclean FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile distclean
sub-tests-install_subtargets: sub-src-install_subtargets FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile install
sub-tests-uninstall_subtargets: sub-src-uninstall_subtargets FORCE
@if not exist tests/ mkdir tests/ & if not exist tests/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd tests/ && ( if not exist Makefile $(QMAKE) /home/admin/qtpi/qtbase/tests/tests.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile ) && $(MAKE) -f Makefile uninstall
sub-qmake-qmake-aux-pro-qmake_all: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
cd qmake/ && $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && $(MAKE) -f Makefile.qmake-aux qmake_all
sub-qmake-qmake-aux-pro: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux
sub-qmake-qmake-aux-pro-make_first: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux
sub-qmake-qmake-aux-pro-all: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux all
sub-qmake-qmake-aux-pro-clean: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux clean
sub-qmake-qmake-aux-pro-distclean: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux distclean
sub-qmake-qmake-aux-pro-install_subtargets: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux install
sub-qmake-qmake-aux-pro-uninstall_subtargets: FORCE
@if not exist qmake/ mkdir qmake/ & if not exist qmake/ exit 1
@set MAKEFLAGS=$(MAKEFLAGS)
cd qmake/ && ( if not exist Makefile.qmake-aux $(QMAKE) /home/admin/qtpi/qtbase/qmake/qmake-aux.pro -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile.qmake-aux ) && $(MAKE) -f Makefile.qmake-aux uninstall
Makefile: qtbase.pro .qmake.conf .qmake.cache mkspecs/win32-msvc2012/qmake.conf mkspecs/features/spec_pre.prf
mkspecs/common/angle.conf
mkspecs/common/msvc-base.conf
mkspecs/common/msvc-desktop.conf
mkspecs/qconfig.pri
mkspecs/features/qt_functions.prf
mkspecs/features/qt_config.prf
mkspecs/features/win32/qt_config.prf
mkspecs/win32-msvc2012/qmake.conf
mkspecs/features/spec_post.prf
mkspecs/qmodule.pri
mkspecs/features/qt_build_config.prf
.qmake.conf
.qmake.stash
mkspecs/features/exclusive_builds.prf
mkspecs/features/default_pre.prf
mkspecs/features/win32/default_pre.prf
mkspecs/features/qt_parts.prf
mkspecs/modules/qt_tool_syncqt.pri
mkspecs/features/resolve_config.prf
mkspecs/features/exclusive_builds_post.prf
mkspecs/features/default_post.prf
mkspecs/features/exceptions_off.prf
mkspecs/features/qt_example_installs.prf
mkspecs/features/qt_docs_targets.prf
mkspecs/features/precompile_header.prf
mkspecs/features/warn_on.prf
mkspecs/features/file_copies.prf
mkspecs/features/qt_build_extra.prf
mkspecs/features/win32/windows.prf
mkspecs/features/win32/rtti_off.prf
mkspecs/features/testcase_targets.prf
mkspecs/features/yacc.prf
mkspecs/features/lex.prf
qtbase.pro
$(QMAKE) -qtconf /home/admin/qtpi/qtbase/bin/qt.conf -o Makefile qtbase.pro
mkspecs/features/spec_pre.prf:
mkspecs/common/angle.conf:
mkspecs/common/msvc-base.conf:
mkspecs/common/msvc-desktop.conf:
mkspecs/qconfig.pri:
mkspecs/features/qt_functions.prf:
mkspecs/features/qt_config.prf:
mkspecs/features/win32/qt_config.prf:
mkspecs/win32-msvc2012/qmake.conf:
mkspecs/features/spec_post.prf:
mkspecs/qmodule.pri:
mkspecs/features/qt_build_config.prf:
.qmake.conf:
.qmake.stash:
mkspecs/features/exclusive_builds.prf:
mkspecs/features/default_pre.prf:
mkspecs/features/win32/default_pre.prf:
mkspecs/features/qt_parts.prf:
mkspecs/modules/qt_tool_syncqt.pri:
mkspecs/features/resolve_config.prf:
mkspecs/features/exclusive_builds_post.prf:
mkspecs/features/default_post.prf:
mkspecs/features/exceptions_off.prf:
mkspecs/features/qt_example_installs.prf:
mkspecs/features/qt_docs_targets.prf:
mkspecs/features/precompile_header.prf:
mkspecs/features/warn_on.prf:
mkspecs/features/file_copies.prf:
mkspecs/features/qt_build_extra.prf:
mkspecs/features/win32/windows.prf:
mkspecs/features/win32/rtti_off.prf:
mkspecs/features/testcase_targets.prf:
mkspecs/features/yacc.prf:
mkspecs/features/lex.prf:
qtbase.pro:
qmake: FORCE
请帮我克服这个!
https://forum.qt.io/topic/69482/cannot-compile-qmake-for-win32-g-cross-compiling
在qt支持论坛的这个链接中,qt5.7在windows上编译时似乎遇到了一些问题。我使用的是5.5版本,它没有问题
基于@Torugobeck指出的cannot-compile-qmake-for-win32-g-交叉编译,我尝试了交叉编译Qt5.5,它似乎已经走过场,在Cygwin-下完成了"make"one_answers"make-install",但使用了Cygwin-g++平台(而不是mingw下的win32-g++平台选项(
配置在上面链接中概述的两个阶段中成功。
从这个配置命令开始:
./configure -prefix /cygdrive/c/qtpi5 -debug-and-release -no-accessibility
-opensource -confirm-license -make libs -platform cygwin-g++
-device linux-rasp-pi2-g++ -sysroot /cygdrive/c/cygwin64/home/admin/x-tools/armv7-rpi2-linux-gnueabihf/armv7-rpi2-linux-gnueabihf/sysroot -v
这成功地为windows生成了qmake二进制文件。
然后编辑/qtbase/configure文件,如上面链接中所述。
继续此配置命令:
./configure -prefix /cygdrive/c/qtpi5 -debug-and-release -no-accessibility
-opensource -confirm-license -make libs -platform cygwin-g++
-device linux-rasp-pi2-g++ -sysroot /cygdrive/c/cygwin64/home/admin/x-tools/armv7-rpi2-linux-gnueabihf/armv7-rpi2-linux-gnueabihf/sysroot
-v -device-option CROSS_COMPILE=/cygdrive/c/cygwin64/home/admin/x-tools/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-
函数/home/admin/qtpi/qtbase/src/corelib/global/qglobal.cpp:determineWinOsVersionPost8 中存在与windows版本检测相关的故障
我强制函数返回true,并在out参数上填写相关的操作系统版本信息。
此配置完成后。'make只花了4个小时就完成了,没有出现任何错误,接下来的make install也是如此。
我编译了一个最小的GUI程序qith qt5,并能够在目标-树莓PI/arm7-linux上执行它。
简而言之,cygwin能够使用使用交叉工具ng生成的linux-armv7交叉编译器成功地交叉编译qt 5.5-也在cygwin下-请参阅UPDATE3。
p.s GUI可执行文件无法启动GUI,似乎只是挂在那里并发出以下警告。。。
libEGL warning: DRI2: failed to authenticate
我正在调查此事。