Qt4.8.2基于Linux平台下的移植
1、 下载安装包qt-everywhere-opensource-src-4.8.2:http://download.qt.io/archive/qt/4.8/4.8.2/
2、 拷贝到linux下并解压得到目录:qt-everywhere-opensource-src-4.8.2
3、 进入到:qt-everywhere-opensource-src-4.8.2
4、 修改文件:mkspec/qws/linux-arm-g++/qmake.conf指定交叉编译工具链及添加第三方库,例:
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)
QMAKE_CC = arm-linux-gcc
QMAKE_CXX = arm-linux-g++
QMAKE_LINK = arm-linux-g++
QMAKE_LINK_SHLIB = arm-linux-g++
QMAKE_CFLAGS += -march=armv7 -mtune=cortex-a9
QMAKE_CFLAGS_DEBUG += -march=armv7 -mtune=cortex-a9 -g
QMAKE_CFLAGS_RELEASE += -march=armv7 -mtune=cortex-a9
QMAKE_CXXFLAGS += -march=armv7 -mtune=cortex-a9
QMAKE_CXXFLAGS_DEBUG += -march=armv7 -mtune=cortex-a9 -g
QMAKE_CXXFLAGS_RELEASE +=-march=armv7 -mtune=cortex-a9
QMAKE_AR = arm-linux-ar cqs
QMAKE_OBJCOPY = arm-linux-objcopy
QMAKE_STRIP =arm-linux-strip
QMAKE_INCDIR += /freetype/include
QMAKE_INCDIR += /freetype/include/freetype2
QMAKE_INCDIR += /zlib/include
QMAKE_INCDIR += /dbus/include/dbus-1.0
QMAKE_INCDIR += /bzip2/include
QMAKE_LIBDIR +=/zlib/usr/lib
QMAKE_LIBDIR += /freetype/usr/lib
QMAKE_LIBDIR += /bus/usr/lib
QMAKE_LIBDIR += /bzip2/usr/lib
QMAKE_LIBS += -ldbus-1
QMAKE_LIBS += -lfreetype
QMAKE_LIBS += -lz
QMAKE_LIBS += -lbz2
5、 修改configure,解决连接dbus问题
Creating qmake. Please wait...
gmake: Nothing to be done for `first'.
The QtDBus module cannot be enabled because libdbus-1 version 0.93 was not found.
Turn on verbose messaging (-v) to ./configure to see the final report.
If you believe this message is in error you may use the continue
switch (-continue) to ./configure to continue.
出现该问题的原因是在configure中dbus路径指定错误
Configure中5660行添加打印,查看结果:
if ["$CFG_DBUS" != "no" ]; then
if [ -n "$PKG_CONFIG" ]&& $PKG_CONFIG --atleast-version="$MIN_DBUS_1_VERSION" dbus-12>/dev/null; then
QT_CFLAGS_DBUS=`$PKG_CONFIG --cflagsdbus-1 2>/dev/null`
QT_LIBS_DBUS=`$PKG_CONFIG--libs dbus-1 2>/dev/null`
echo"QT_CFLAGS_DBUS====="$QT_CFLAGS_DBUS
echo "QT_LIBS_DBUS====="$QT_LIBS_DBUS
fi
if "$unixtests/compile.test""$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE"$relpath" "$outpath" config.tests/unix/dbus"D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS$MAC_CONFIG_TEST_COMMANDLINE; then
[ "$CFG_DBUS" ="auto" ] && CFG_DBUS=yes
QMakeVar set QT_CFLAGS_DBUS"$QT_CFLAGS_DBUS"
QMakeVar set QT_LIBS_DBUS"$QT_LIBS_DBUS"
else
if [ "$CFG_DBUS" ="auto" ]; then
CFG_DBUS=no
elif ["$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
# CFG_DBUS is "yes" or"linked" here
echo "The QtDBus module cannotbe enabled because libdbus-1 version $MIN_DBUS_1_VERSION was not found."
echo " Turn on verbosemessaging (-v) to $0 to see the final report."
echo " If you believe thismessage is in error you may use the continue"
echo " switch (-continue) to$0 to continue."
exit101
fi
fi
fi
如果错误,可直接修改:QT_CFLAGS_DBUS QT_LIBS_DBUS
6、 配置,如:
./configure \
-prefix /usr/local/qt4.8.2-embedded\
-host-little-endian \
-little-endian \
-opensource \
-confirm-license \
-no-rpath \
-shared \
-fast \
-optimized-qmake \
-embedded armv7 \
-xplatform qws/linux-arm-g++\
-qt-kbd-linuxinput \
-qt-mouse-pc \
-no-qt3support \
-no-javascript-jit \
-no-phonon \
-no-webkit \
-no-declarative \
-no-declarative-debug \
-release \
-nomake examples \
-dbus-linked \
-system-freetype \
-system-zlib \
7、 make –jN
8、 make install
/usr/local/qt4.8.2-embedded目录下即编译好的库