(二)QT编译环境和移植开发板QT运行环境库
程序员文章站
2022-05-28 11:49:47
...
文章为作者原创,转载请附明原地址:https://mp.csdn.net/postedit/80099394
上面我们已经吧tslib库一直好了,详情请看https://mp.csdn.net/postedit/80099257,现在进行QT编译环境和开发板QT运行环境库的移植。
一、下载qt-4.6.4并安装
我的下载在/home/shun/fl2440/fl2440_1/QT/qt路径下。
[aaa@qq.com qt]$ ls
qt-everywhere-opensource-src-4.6.4.tar.gz
[aaa@qq.com qt]$ tar -zxvf qt-everywhere-opensource-src-4.6.4.tar.gz
[aaa@qq.com qt]$ cd qt-everywhere-opensource-src-4.6.4
[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ vim src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp //修改文件
-- (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 30)
++(__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 32) && defined(__LINUXTHREADS_OLD__)
写脚本:
[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ vim build.sh
#!/bin/sh
./configure -prefix /opt/qt4/ \
-release \
-shared \
-fast \
-no-largefile \
-qt-sql-sqlite \
-no-qt3support \
-no-xmlpatterns \
-no-mmx \
-no-3dnow \
-no-sse \
-no-sse2 \
-no-svg \
-no-webkit \
-qt-zlib \
-qt-gif \
-qt-libtiff \
-qt-libpng \
-qt-libmng \
-qt-libjpeg \
-qt-gfx-transformed \
-qt-gfx-linuxfb \
-make libs \
-xplatform qws/linux-arm-g++ \
-nomake tools \
-nomake examples \
-nomake docs \
-nomake demo \
-no-nis \
-no-cups \
-no-iconv \
-no-dbus \
-no-openssl \
-embedded arm \
-little-endian \
-qt-freetype \
-depths 16,18 \
-no-glib \
-qt-mouse-tslib \
-no-javascript-jit \
-no-script \
-no-scripttools \
[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ chmod a+x build.sh
[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ vim mkspecs/qws/linux-arm-g++/qmake.conf //修改qmake.conf
#
# qmake configuration for building with arm-linux-g++
#
include(../../common/g++.conf)
include(../../common/linux.conf)
include(../../common/qws.conf)
#add by liushun 2018/04/23
QMAKE_INCDIR = /opt/tslib/include
QMAKE_INCDIR = /opt/tslib/lib
# modifications to g++.conf
# change by liushun 2018/04/23
QMAKE_CC = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc -lts
QMAKE_CXX = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-g++ -lts
QMAKE_LINK = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-g++ -lts
QMAKE_LINK_SHLIB = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-g++ -lts
# modifications to linux.conf
# change by liushun 2018/04/23
QMAKE_AR = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-objcopy
QMAKE_STRIP = /opt/x-tools/arm920t/bin/arm-arm920t-linux-gnueabi-strip
load(qt_config)
再修改src/gui/itemviews/qabstractitemview.cpp[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ vim src/gui/itemviews/qabstractitemview.cpp
--case Qt::Key_BackSpace:
++case Qt::Key_Backspace:
执行脚本[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ ./build.sh
执行有个选项选择“o”执行完了sudo make && sudo make install
[aaa@qq.com qt-everywhere-opensource-src-4.6.4]$ sudo make && sudo make install
再把安装路径/opt/qt4/下的bin文件夹里的qmake传到虚拟机上的 /usr/local/bin目录下,并修改虚拟机的环境变量。
[aaa@qq.com opt]$ sudo mv qt4/bin/qmake /usr/local/bin/
[aaa@qq.com opt]$ cd ~
[aaa@qq.com ~]$ vim /home/shun/.bash_profile
export QT=/opt/qt5
export QTLIB=$QT/lib
export QTBIN=$QT/bin
ok!Linux下QT程序编译环境搭建完成。但最终目的是要在开发板上把qt程序跑起来,所以还需要在开发板上搭建qt运行环境。把qt5/lib/目录下的fonts文件夹,把它打包放到开发板上解压并把环境变量设置好就ok。
[aaa@qq.com lib]$ tar -czf fonts.tar.gz fonts/ //这里在Linux
/liushun/download >: tftp -gr fonts.tar.gz 192.168.2.8 //这里在开发板,/liushun/download是我创建的文件夹
/liushun/download >: tar -xzvf fonts.tar.gz
/liushun/download/fonts >: cd ~
~ >: vim /etc/profile // 添加下面部分
export QWS_MOUSE_PROTO=TSLIB:/dev/input/event0
export QTLIB=/liushun/download
export QT_QWS_FONTDIR=/liushun/download/fonts
到这里开发板的qt运行环境就搭建好了,以后可以把可执行文件拿到开发板上运行了。