目录
前言
最近总是各种开发环境的搭建,发现不同的Qt5版本的交叉编译会随着交叉编译工具链、Qt5本身版本等问题出现不一样的错误。我在编译Qt5.5.1的时候原来使用arm-eabi-c++编译出错,但是换成arm-linux-gnueabihf-c++configure就成功了!!!浪费了一整天,还好有hlr大神指导,一天都喂狗了!所以交叉编译也是一个大坑!!!
Qt5.5.1下载地址
Qt5.5.1解压缩
这次发现有一种新的压缩格式***.tar.xz,压缩率很高,附上解压缩的方法:
unxz qt-everywhere-opensource-src-5.5.1.tar.xz
tar xf qt-everywhere-opensource-src-5.5.1.tar -C /opt/xxx/
注:.tar.xz的解压需要两步;-C /opt/xxx用于指定解压目录
有时间要总结一下Ubuntu下的常用命令,省得每次都要四处百度。
Qt5.5.1的G6818版本交叉编译
Qt5.5.1的交叉编译环境
Linux:Ubuntu16.04
CrossCompile:gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar
Qt5.5.1编译选项参考
本以为不同的Qt5版本的编译选项会是一样的,但是实际上我发现有些编译选项是不一样的,这里列出我发现的几个不同的编译选项的写法。
-c++11和-no-c++11:
默认是编译c++11的,但是在Qt5.6.2中选项是这样的:-c++std <edition>
配置过程参考Ubuntu下Qt5.6.2开发环境搭建
编译选项如下:
./configure -prefix /opt/qt5.5.1-grape\
-v \
-opensource \
-confirm-license \
-release \
-shared \
-accessibility \
-c++11 \
-xplatform linux-arm-6818-g++ \
-qpa linuxfb \
-linuxfb \
-qreal float \
-pch \
-qt-zlib \
-qt-libjpeg \
-qt-libpng \
-qt-freetype \
-no-sse2 \
-no-largefile \
-no-qml-debug \
-no-gtkstyle \
-no-opengl \
-no-openssl \
-no-iconv \ # 不加会出现:iconv_open failed
-nomake tools \
-nomake examples \
-skip qt3d -skip qtcanvas3d -skip qtdoc -skip qtwayland
执行成功:
make:
出现错误1:
painting/qpdf.cpp:2160:41: error: ambiguous overload for ‘operator<<’ (operand types are ‘QPdf::ByteStream’ and ‘double’)
"/Coords [" << p0.x() << p0.y() << r0 << p1.x() << p1.y() << r1 << "]\n"
解决方法1:进入qt-everywhere-opensource-src-5.5.1\qtbase\src\gui\painting\qpdf.cpp
注释掉2154行如下内容
#if 0
s << "<<\n"
"/ShadingType 3\n"
"/ColorSpace " << (alpha ? "/DeviceGray\n" : "/DeviceRGB\n") <<
"/AntiAlias true\n"
"/Domain [0 1]\n"
"/Coords [" << p0.x() << p0.y() << r0 << p1.x() << p1.y() << r1 << "]\n"
"/Extend [true true]\n"
"/Function " << function << "0 R\n"
">>\n"
"endobj\n";
#endif
出现错误2:
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isAlphanumeric(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:136:58: error: ‘iswalnum’ was not declared in this scope
inline bool isAlphanumeric(UChar c) { return !!iswalnum(c); }
^
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isDigit(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:137:51: error: ‘iswdigit’ was not declared in this scope
inline bool isDigit(UChar c) { return !!iswdigit(c); }
^
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isLetter(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:138:52: error: ‘iswalpha’ was not declared in this scope
inline bool isLetter(UChar c) { return !!iswalpha(c); }
^
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isLower(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:139:51: error: ‘iswlower’ was not declared in this scope
inline bool isLower(UChar c) { return !!iswlower(c); }
^
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isPrintableChar(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:140:59: error: ‘iswprint’ was not declared in this scope
inline bool isPrintableChar(UChar c) { return !!iswprint(c); }
^
./wtf/unicode/wchar/UnicodeWchar.h: In function ‘bool WTF::Unicode::isPunct(UChar)’:
./wtf/unicode/wchar/UnicodeWchar.h:141:51: error: ‘iswpunct’ was not declared in this scope
inline bool isPunct(UChar c) { return !!iswpunct(c); }
解决方法:vi qtwebkit/Source/WTF/wtf/unicode/wchar/UnicodeWchar.h
第32行
#ifndef ANDROID
# include <wchar.h>
typedef wchar_t UChar;
#else
typedef unsigned short int UChar;
#endif
修改为:
#ifndef ANDROID
#include <wctype.h>
typedef unsigned short int UChar;
//# include <wchar.h>
// typedef wchar_t UChar;
#else
typedef unsigned short int UChar;
#endif
使用arm-eabi-gcc的配置错误
因为我编译的Qt版本比较高,但是使用的arm-eabi-gcc的版本较低,所以在配置的时候就会出现错误,下面附上配置时的错误信息,解决方法可以尝试一下用更高版本的交叉编译工具链。
错误信息:
collect2: fatal error: cannot find 'ld'
compilation terminated.
/grapeRain/g6818_linux/gcc/linux-x86/arm/arm-eabi-4.8/bin/../lib/gcc/arm-eabi/4.8/../../../../arm-eabi/bin/ld: cannot find crt0.o: 没有那个文件或目录
/grapeRain/g6818_linux/gcc/linux-x86/arm/arm-eabi-4.8/bin/../lib/gcc/arm-eabi/4.8/../../../../arm-eabi/bin/ld: cannot find -lstdc++
/grapeRain/g6818_linux/gcc/linux-x86/arm/arm-eabi-4.8/bin/../lib/gcc/arm-eabi/4.8/../../../../arm-eabi/bin/ld: cannot find -lm
/grapeRain/g6818_linux/gcc/linux-x86/arm/arm-eabi-4.8/bin/../lib/gcc/arm-eabi/4.8/../../../../arm-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
运行时错误1:
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
解决方法:在配置选项中加入-no-iconv
tslib-1.4的交叉编译
编译
- 下载tslib-1.4.tar.gz
- 解压
- 执行
./autogen.sh’
出现错误:./autogen.sh: 4: ./autogen.sh: autoreconf: not found
解决方法:sudo apt-get install autoconf automake libtool - echo “ac_cv_func_malloc_0_nonnull=yes”>arm-linux.cache
- mkdir /opt/tslib
- ./configure –prefix=/opt/tslib –host=arm-linux-gnueabihf –cache-file=arm-linux.cache
- make
- make install
导出环境变量
export TSLIB_ROOT=/opt/tslib
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export TSLIB_TSDEVICE=/dev/input/mouse2
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export LD_LIBRARY_PATH=/lib:/usr/lib:$TSLIB_ROOT/lib
export TS_INFO_FILE=/sys/class/input/mouse2/uevent
执行tslib/bin目录下的测试文件
出现错误:
No raw modules loaded.
Ts_config: No such file or directory
解决方法:
vi etc/ts.conf
打开module raw input的注释
总结
Qt的版本不同,交叉编译选项也不同,同时注意不要使用低版本的交叉编译工具链去编译高版本的Qt,这样就会出现许多莫名其妙,百度一天都无法解决的问题,以后要逐步学会使用google!
893



被折叠的 条评论
为什么被折叠?



