基于Ixm6q,移植Qt5.9.1(动态库)
一、准备好Qt5.9.1与tslib库
1.方法1:
- Qt5.9.1源码下载路径:http://download.qt.io/archive/qt/5.9/5.9.1/single/
- QtCreator5.9.1:http://download.qt.io/official_releases/qt/5.9/5.9.1/
- tslib下载路径:https://github.com/kergoth/tslib
2.方法2:
- 链接:https://pan.baidu.com/s/13-4vFnQ4eErShMn-B4Pc1w
- 提取码:mck3
二、配置Ixm6q开发环境
1.使能Ixm6q开发环境:
- source /opt/fsl-imx/4.1.15-2.1.0/fb/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
2.测试编译链:
- 运行命令:echo $CC
- 结果:arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx/4.1.15-2.1.0/fb/sysroots/cortexa9hf-neon-poky-linux-gnueabi
三、安装tslib
四、解压Qt5.9.1
- 下载源码包qt-everywhere-opensource-src-5.9.1.tar.xz,并将源码包拷贝到Ubuntu的Desktop。
- 解压qt-everywhere-opensource-src-5.9.1.tar.xz
- 修改解压后源码包权限:sudo chmod 755 qt-everywhere-opensource-src-5.9.1 -R
五、配置qmake.conf交叉编译参数
- 进入源码包:cd ~/Desktop/qt-everywhere-opensource-src-5.9.1
- 拷贝创建arm-poky-linux-gnueabi-g++,命令cp qtbase/mkspecs/linux-arm-gnueabi-g++/ qtbase/mkspecs/arm-poky-linux-gnueabi-g++/ -r
- 修改qtbase/mkspecs/arm-poky-linux-gnueabi-g++/qmake.conf文件
-
MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) #Ixm6系统开发环境配置参数 IMX6_CFLAGS = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1 IMX6_CFLAGS_RELEASE = -O2 $$IMX6_CFLAGS QMAKE_CFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE QMAKE_CFLAGS_DEBUG += $$IMX6_CFLAGS QMAKE_CXXFLAGS_DEBUG += $$IMX6_CFLAGS CPPFLAGS = -DNDEBUG -g2 -O3 CFLAGS = -ffunction-sections -fdata-sections CXXFLAGS = -ffunction-sections -fdata-sections LDFLAGS = -gc-sections QMAKE_INCDIR = /qt5.9.1/usr/include QMAKE_LIBDIR = /qt5.9.1/lib EGLFS_DEVICE_INTEGRATION = eglfs_viv QT_QPA_DEFAULT_PLATFORM = linuxfb #QPA显示插件linuxfb,还有eglf等可选 PKG_CONFIG_SYSROOT_DIR = $SDKTARGETSYSROOT #ixm6q开发SDK路径:/opt/fsl-imx/4.1.15-2.1.0/fb/sysroots/cortexa9hf-neon-poky-linux-gnueabi PKG_CONFIG_LIBDIR = /qt5.9.1/usr/local/Qt5.9.1/lib # modifications to g++.conf QMAKE_CC = arm-poky-linux-gnueabi-gcc -O2 -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT QMAKE_CXX = arm-poky-linux-gnueabi-g++ -O2 -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT QMAKE_LINK = arm-poky-linux-gnueabi-g++ -O2 -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT QMAKE_LINK_SHLIB = arm-poky-linux-gnueabi-g++ -O2 -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT # modifications to linux.conf QMAKE_AR = arm-poky-linux-gnueabi-ar cqs QMAKE_OBJCOPY = arm-poky-linux-gnueabi-objcopy QMAKE_NM = arm-poky-linux-gnueabi-nm -P QMAKE_STRIP = arm-poky-linux-gnueabi-strip load(qt_config)
六、配置Qt编译选项
- 配置编译选项
-
./configure -v -prefix /qt5.9.1 -sysroot /opt/fsl-imx/4.1.15-2.1.0/fb/sysroots/cortexa9hf-neon-poky-linux-gnueabi -xplatform arm-poky-linux-gnueabi-g++ -no-opengl -nomake examples -nomake tools -no-separate-debug-info -qreal float -qt-zlib -skip qtdeclarative -skip qtlocation -no-gtk -no-gstreamer -no-glib -linuxfb -tslib -I/opt/tslib1.4/include -L/opt/tslib1.4/lib -recheck-all
- 选项简要解析
- 指定Ixm6开发SDK路径:-sysroot /opt/fsl-imx/4.1.15-2.1.0/fb/sysroots/cortexa9hf-neon-poky-linux-gnueabi
- 指定安装路径:-prefix /qt5.9.1,但安装绝对路径是 /opt/fsl-imx/4.1.15-2.1.0/fb/sysroots/cortexa9hf-neon-poky-linux-gnueabi/qt5.9.1
- 指定交叉编译qmake.conf:-xplatform arm-poky-linux-gnueabi-g++
- 指定tslib触摸库(但因没用上触摸库,所以没有测试):-tslib -I/opt/tslib1.4/include -L/opt/tslib1.4/lib
- 检测所有配置选项:-recheck-all
七、编译与安装
- 编译:make
- 安装:make install
八、安装QtCreator
- 运行安装:sudo ./qt-opensource-linux-x64.run
- 根据提示,选择安装即可
九、配置QtCreator套件
- 打开QtCreator,Tools->Options->Build & Run
- 添加编译链
- 选择Qt version
- 配置Qt的套件kit
十、在Ixm6q开发板,配置Qt运行环境及移植Qt库
- 移植Qt5.9.1库,tslib库及程序运行依赖库到Ixm6q的/usr/local
-
local/ ├── projectLibs │ ├── libsv_avm.so │ ├── libsv_globalXml.so │ ├── libsv_gui.so.1 │ ├── libsv_media_buf.so │ ├── libsv_storage.so │ ├── libsv_vi.so │ └── libsv_vpu.so ├── Qt5.9.1 │ ├── fontconfig │ │ ├── libfontconfig.so.1 │ │ ├── libfreetype.so.6 │ │ ├── libharfbuzz.so.0 │ │ ├── local.conf │ │ └── wqy-microhei.ttc │ ├── lib │ │ ├── libQt5Core.so.5 │ │ ├── libQt5DBus.so.5 │ │ ├── libQt5Gui.so.5 │ │ └── libQt5Widgets.so.5 │ ├── plugins │ │ └── platforms │ │ ├── libqeglfs.so │ │ ├── libqlinuxfb.so │ │ ├── libqminimalegl.so │ │ ├── libqminimal.so │ │ ├── libqoffscreen.so │ │ └── libqvnc.so │ └── qtRelyLib │ ├── libicudata.so.56 │ ├── libicui18n.so.56 │ ├── libicuuc.so.56 │ └── libidn.so.11 -> libidn.so.11.6.15 └── tslib ├── bin │ ├── ts_calibrate │ ├── ts_harvest │ ├── ts_print │ ├── ts_print_raw │ └── ts_test ├── etc │ └── ts.conf ├── include │ └── tslib.h └── lib ├── libts-0.0.so.0 -> libts-0.0.so.0.1.1 ├── libts-0.0.so.0.1.1 ├── libts.la ├── libts.so -> libts-0.0.so.0.1.1 ├── pkgconfig │ └── tslib-0.0.pc └── ts ├── arctic2.la ├── arctic2.so ├── collie.la ├── collie.so ├── corgi.la ├── corgi.so ├── dejitter.la ├── dejitter.so ├── h3600.la ├── h3600.so ├── input.la ├── input.so ├── linear_h2200.la ├── linear_h2200.so ├── linear.la ├── linear.so ├── mk712.la ├── mk712.so ├── pthres.la ├── pthres.so ├── ucb1x00.la ├── ucb1x00.so ├── variance.la └── variance.so
- 配置/etc/profile
-
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_PATH=$TSLIB_ROOT/lib
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONSOLEDEVICE=noneexport QTDIR=/usr/local/Qt5.9.1
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
export QTLIB_PATH=$QTDIR/lib
export QTRELYLIBS_PATH=$QTDIR/qtRelyLib
export FONTCONFIG_PATH=$QTDIR/fontconfigexport LD_LIBRARY_PATH=$TSLIB_PATH:$QTLIB_PATH:$QTRELYLIBS_PATH:$FONTCONFIG_PATH:$LD_LIBRARY_PATH
export PATH=$PATH:$LD_LIBRARY_PATH
十一、Qt程序测试
- 配置/dev/fb0运行参数
-
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha) #define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key) #define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha) struct mxcfb_gbl_alpha { int enable; int alpha; }; struct mxcfb_loc_alpha { int enable; int alpha_in_pixel; unsigned long alpha_phy_addr0; unsigned long alpha_phy_addr1; }; struct mxcfb_color_key { int enable; unsigned int color_key; }; bool setGuiFbSetup(std::string fbName) { int s32Fd = -1; if(true == fbName.empty()) { return false; } if(0 > (s32Fd = open(fbName.c_str(),O_RDWR,0))) { return false; } struct fb_var_screeninfo stScreen_info; if(ioctl(s32Fd, FBIOGET_VSCREENINFO, &stScreen_info) < 0) { close(s32Fd); return false; } stScreen_info.xres = 1920; stScreen_info.yres = 1080; stScreen_info.xres_virtual = 1920; stScreen_info.yres_virtual = 1080; stScreen_info.xoffset = 0; stScreen_info.yoffset = 0; stScreen_info.bits_per_pixel = 16; if(ioctl(s32Fd, FBIOPUT_VSCREENINFO, &stScreen_info) < 0) { close(s32Fd); return false; } struct mxcfb_gbl_alpha gbl_alpha; gbl_alpha.enable = 1; gbl_alpha.alpha = 255; // BG opaque ioctl(s32Fd, MXCFB_SET_GBL_ALPHA, &gbl_alpha); struct mxcfb_color_key key; key.enable = 1; key.color_key = 0x00000000; // Black ioctl(s32Fd, MXCFB_SET_CLR_KEY, &key); if(ioctl(s32Fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) { close(s32Fd); return false; } close(s32Fd); return true; }
- 因Qt5没有自带字库,需要在运行界面之前,加载字库。
-
void sv_gui::sv_setGuiRunningFontLibrary(const QApplication &a) { int s32Index = QFontDatabase::addApplicationFont(":/language/language/wqy-microhei.ttc"); if (-1 != s32Index) { QStringList strList(QFontDatabase::applicationFontFamilies(s32Index)); if (strList.count() > 0) { QFont fontThis(strList.at(0)); fontThis.setPointSize(32); a.setFont(fontThis); } } }
- 程序测试:主要测试移植后的Qt是否能正常出界面