zl程序教程

您现在的位置是:首页 >  系统

当前栏目

嵌入式linux开发,交叉编译qt4.8.5报错:Makefile:1054: recipe for target ‘.moc/release-shared-emb-arm/moc_qabstract

Linux嵌入式ARM开发 报错 for 编译 交叉
2023-09-14 09:09:33 时间

一、问题描述。

嵌入式linux开发,交叉编译qt4.8.5,执行make时报错如下:

ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ make -j4
cd src/tools/bootstrap/ && make -f Makefile 
make[1]: Entering directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/bootstrap'
make[1]: Nothing to be done for 'first'.
make[1]: Leaving directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/bootstrap'
cd src/tools/moc/ && make -f Makefile 
make[1]: Entering directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/moc'
make[1]: Nothing to be done for 'first'.
make[1]: Leaving directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/moc'
cd src/tools/rcc/ && make -f Makefile 
make[1]: Entering directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/rcc'
make[1]: Nothing to be done for 'first'.
make[1]: Leaving directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/rcc'
cd src/tools/uic/ && make -f Makefile 
make[1]: Entering directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/uic'
make[1]: Nothing to be done for 'first'.
make[1]: Leaving directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/tools/uic'
cd src/corelib/ && make -f Makefile 
make[1]: Entering directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/corelib'
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/qws/linux-arm-gnueabi-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/zlib -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm animation/qabstractanimation.h -o .moc/release-shared-emb-arm/moc_qabstractanimation.cpp
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/qws/linux-arm-gnueabi-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/zlib -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm animation/qvariantanimation.h -o .moc/release-shared-emb-arm/moc_qvariantanimation.cpp
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/qws/linux-arm-gnueabi-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/zlib -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm animation/qpropertyanimation.h -o .moc/release-shared-emb-arm/moc_qpropertyanimation.cpp
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: 1: /home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: Syntax error: word unexpected (expecting ")")
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/qws/linux-arm-gnueabi-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/zlib -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm animation/qanimationgroup.h -o .moc/release-shared-emb-arm/moc_qanimationgroup.cpp
Makefile:1054: recipe for target '.moc/release-shared-emb-arm/moc_qabstractanimation.cpp' failed
make[1]: *** [.moc/release-shared-emb-arm/moc_qabstractanimation.cpp] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: 1: /home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: Syntax error: word unexpected (expecting ")")
Makefile:1427: recipe for target '.moc/release-shared-emb-arm/moc_qpropertyanimation.cpp' failed
make[1]: *** [.moc/release-shared-emb-arm/moc_qpropertyanimation.cpp] Error 2
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: 1: /home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: Syntax error: word unexpected (expecting ")")
/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: 1: /home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/bin/moc: Syntax error: word unexpected (expecting ")")
Makefile:1522: recipe for target '.moc/release-shared-emb-arm/moc_qanimationgroup.cpp' failed
make[1]: *** [.moc/release-shared-emb-arm/moc_qanimationgroup.cpp] Error 2
Makefile:1310: recipe for target '.moc/release-shared-emb-arm/moc_qvariantanimation.cpp' failed
make[1]: *** [.moc/release-shared-emb-arm/moc_qvariantanimation.cpp] Error 2
make[1]: Leaving directory '/home/ms/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5/src/corelib'
Makefile:204: recipe for target 'sub-corelib-make_default-ordered' failed
make: *** [sub-corelib-make_default-ordered] Error 2
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ 

二、问题分析。

查看bin文件夹下的内容,新生成的文件有 moc、qmake、rcc、uic 四个文件。

ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ ll ./bin/
total 30264
drwxr-xr-x  2 ms ms     4096 Jul  3 18:59 ./
drwxr-xr-x 21 ms ms     4096 Jul  3 18:49 ../
-rwxr-xr-x  1 ms ms       73 Jun  7  2013 createpackage*
-rwxr-xr-x  1 ms ms     2034 Jun  7  2013 createpackage.bat*
-rwxr-xr-x  1 ms ms    16603 Jun  7  2013 createpackage.pl*
-rwxr-xr-x  1 ms ms       77 Jun  7  2013 elf2e32_qtwrapper*
-rw-r--r--  1 ms ms       72 Jun  7  2013 elf2e32_qtwrapper.bat
-rwxr-xr-x  1 ms ms    11024 Jun  7  2013 elf2e32_qtwrapper.pl*
-rwxr-xr-x  1 ms ms     4160 Jun  7  2013 findtr*
-rwxrwxr-x  1 ms ms  1252034 Jul  3 18:58 moc*
-rwxr-xr-x  1 ms ms       78 Jun  7  2013 patch_capabilities*
-rw-r--r--  1 ms ms       43 Jun  7  2013 patch_capabilities.bat
-rwxr-xr-x  1 ms ms    16982 Jun  7  2013 patch_capabilities.pl*
-rwxrwxr-x  1 ms ms 26542576 Jul  3 18:00 qmake*
-rwxrwxr-x  1 ms ms  1334643 Jul  3 18:58 rcc*
-rwxr-xr-x  1 ms ms     8489 Jun  7  2013 setcepaths.bat*
-rwxr-xr-x  1 ms ms    49356 Jun  7  2013 syncqt*
-rwxr-xr-x  1 ms ms     2046 Jun  7  2013 syncqt.bat*
-rwxrwxr-x  1 ms ms  1689755 Jul  3 18:59 uic*
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$

 分别查看四个文件属性,发现编译的部分文件为arm下的执行文件,生成的四个新文件应都为x86下的可执行文件。

ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ file ./bin/moc
./bin/moc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ file ./bin/qmake 
./bin/qmake: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=af6cf3584e066fd5127f354d26287e79280ab481, with debug_info, not stripped
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ file ./bin/rcc 
./bin/rcc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ file ./bin/uic 
./bin/uic: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped
ms@ubuntu:~/work/code/qt/opensource/qt-everywhere-opensource-src-4.8.5$ 

三、解决方案。

1、研究调整配置,未解决,配置如下:

./configure \
 -prefix /home/ms/work/product/ok335xD/tool/toolchain/qt4.8.5 \
 -release \
 -opensource \
 -shared \
 -fast \
 -qt-sql-sqlite \
 -no-qt3support \
 -no-phonon \
 -webkit \
 -platform qws/linux-x86_64-g++ \
 -no-mmx \
 -no-3dnow \
 -no-sse \
 -no-sse2 \
 -I/usr/local/arm/tslib/include \
 -L/usr/local/arm/tslib/lib \
 -qt-zlib \
 -no-libtiff\
 -qt-libtiff \
 -qt-libpng \
 -no-libmng \
 -qt-libmng \
 -no-libjpeg \
 -qt-libjpeg \
 -no-openssl \
 -nomake docs \
 -optimized-qmake \
 -no-nis \
 -no-cups \
 -pch \
 -no-separate-debug-info \
 -embedded arm \
 -xplatform qws/linux-arm-g++ \
 -little-endian \
 -host-little-endian \
 -qt-freetype \
 -depths 16,18,24,32 \
 -qt-gfx-linuxfb \
 -qt-gfx-transformed \
 -qt-kbd-linuxinput \
 -qt-mouse-linuxinput \
 -qt-mouse-tslib \
 -no-glib \
 \
 -confirm-license \
 -no-opengl \
 -no-qvfb 
# -verbose

2、一天后,执行清除,去掉arm平台相关的两个参数,未解决,吐血。

make clean
make confclean
 -embedded arm \
 -xplatform qws/linux-arm-g++ \

3、一天后,更换交叉编译器,执行清除后编译,问题依旧。查看moc文件夹下相关文件,Makefile文件日期不变。最终确定,执行清除未能删除Makefile文件,删除源码,重新解压和配置,问题解决。

4、经确认,没有生成新 Makefile 文件的原因是使用了 -fast 参数,应用使用 -no-fast 。