“MY-IMX6-EK140 Qt4.8.5移植”的版本间的差异

来自明远智睿的wiki
跳转至: 导航搜索
 
第1行: 第1行:
 +
<div>
  
 
= 移植ARM版的Qt4.8(porting Qt4.8 of ARM version) =
 
= 移植ARM版的Qt4.8(porting Qt4.8 of ARM version) =
第166行: 第167行:
 
9 编译,点击左下角的锤子形状的按钮编译,编译完成会在创建目录生成可执行文件,把它放到开发板上就可以运行了。<br>
 
9 编译,点击左下角的锤子形状的按钮编译,编译完成会在创建目录生成可执行文件,把它放到开发板上就可以运行了。<br>
 
<span style="background:#CCCCCC">Compile, click the lower left corner of the hammer shape button to compile, compile will be created in the directory to create an executable file, put it on the development board can run. <br>
 
<span style="background:#CCCCCC">Compile, click the lower left corner of the hammer shape button to compile, compile will be created in the directory to create an executable file, put it on the development board can run. <br>
 +
</div>

2018年6月11日 (一) 15:32的最新版本

移植ARM版的Qt4.8(porting Qt4.8 of ARM version)

tslib移植(tslib porting)

编译tslib库(Compile tslib library)

1 解压tslib (unzip tslib)

unzip tslib-master
2 进入tslib目录,指定交叉编译工具
Into the tslib directory, specify the cross-compile tools
export CC=/home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-gcc-4.9.23

3 生成配置文件 (generate the configuration file)

./autogen.sh
4 配置 (configure)

./configure --host=arm-linux-gnueabihf --prefix=/usr/local/tslib
5 编译 (compile)

make
6 安装(install)

sudo make install
会在/usr/local下生成tslib目录,安装完成
Tslib directory will be generated in / usr / local when the installation is completed.

7 进入交叉编译工具的库的目录,把编译好的tslib的库复制到交叉编译工具的库的目录
Get into the cross-compiler tools library directory, copy the compiled tslib library to cross-compile tools library directory

cp /usr/local/tslib/lib/libts* ./ -a



移植Qt (porting Qt)

编译Qt库(Compile tslib library)

1 解压Qt源码 (unzip Qt source code)

tar xvf qt-everywhere-opensource-src-4.8.5
2 进入Qt源码目录(Get into Qt source code directory)

vim mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf
3 修改交叉编译工具 (revise cross-compile tools)

  # modifications to g++.conf
  QMAKE_CC = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-gcc-4.9.2 -lts
  QMAKE_CXX = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts
  QMAKE_LINK = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts
  QMAKE_LINK_SHLIB = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts

  # modifications to linux.conf
  QMAKE_AR = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-ar cqs
  QMAKE_OBJCOPY = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-objcopy
  QMAKE_STRIP = /home/myzr/6ul-tools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-strip
  保存退出(Save & Esc)

4 vim mkspecs/common/linux.conf

在QMAKE_LIBS_THREAD = -lpthread 后面添加(Added later) -lts :
QMAKE_LIBS_THREAD = -lpthread -lts
保存退出(Save & Esc)
5 配置 (configure)

./configure -embedded arm -xplatform qws/linux-arm-gnueabi-g++ -little-endian -host-little-endian -no-opengl -no-openssl -nomake examples -nomake docs
6 编译 (compile)

make
编译时间1-2小时(configure needs about 1-2 hours)
7 安装 (install)

sudo make install
安装完成,会在/usr/local目录下生成Trolltech目录。
Trolltech will be generated in / usr / local directory when the installation is completed.

编译tslib插件(compile tslib plugin)

1 在Qt源码目录 (in Qt source code directory)

cd src/plugins/generic/tslib/
2 复制tslib头文件到当前目录 Copy the tslib header file to the current directory cp /usr/local/tslib/include/tslib.h ./

3 编译 (compile)

make
4 安装 (install)

sudo make install
安装完成,会在/usr/local/Trolltech/QtEmbedded-4.8.5-arm/plugins/generic/目录下生成libqtslibplugin.so
libqtslibplugin.so will be generated in /usr/local/Trolltech/QtEmbedded-4.8.5-arm/plugins/generic/ local directory when the installation is completed.

开发板环境搭建(Development board environment building)

拷贝库(copy library)

1 把/usr/local下的Trolltech 目录 复制到 开发板的 /usr/local目录下
Copy Trolltech directory in /usr/local to /usr/local directory in development board


2 把/usr/local 下的tslib 目录 复制到 开发板的 /usr/local 目录下
Copy tslib directory in /usr/local to /usr/local directory in development board


设置环境变量(set environment variables)

1 vi /etc/profile

加入(add):
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_FBDEVICE=/dev/fb0

export LD_LIBRARY=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib
export QT_QWS_FONTDIR=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib/fonts
export QWS_MOUSE_PROTO=tslib:/dev/input/event1
保存退出(Save & Esc)
到此, 开发版的Qt运行环境就搭建好了。
Now, the Qt operating environment of development board has been set up.

Qt应用程序的编译(Qt application compilation)

设置Qtcreator环境(set up Qtcreator environment)

1 到Qt官网下载Qt安装包(Download Qt installation package from Qt’s website): http://download.qt.io/archive/qt/5.5/5.5.0/

qt-opensource-linux-x86-5.5.0.run 是linux下32位的(32 bit);
qt-opensource-linux-x64-5.5.0-2.run 是linux 下64位的(64 bit)。
根据需要下载。(download as needed)
2 下载完成后把安装包放到linux下,用鼠标双击运行,会弹出安装界面,根据自己需求安装。
Put the installation package into linux after downloading, double-click with the mouse to run, will pop-up installation interface, install it according to your needs.

3 安装完成后会得到一个Qt Creator(Community),在桌面可能看不到,可以在linux下搜索“Qt”,然后打开它;也可以在Qt安装目录下的Tools/QtCreator/bin/找到qtcreator,然后运行它,打开之后
You will get a Qt Creator (Community) after the installation is completed , may not be visible on the desktop, you can search for "Qt" in linux and open it; you can also find qtcreator in the Qt installation directory under Tools / QtCreator / bin / , then open it and run it.

  在菜单栏里Tools -> Options ;找到"Build & Run"。(To find “Build & Run" in menu Tools -> Options
添加“Compilers”,“add”添加交叉编译工具,选择前面编译Qt源码的交叉编译工具。
Add "Compilers", "add" add cross compiler tools, select the front compiler Qt source cross compiler tools

添加“Qt Versions”, “add”添加qmake,选择前面编译好的qmake(/usr/local/bin/qmake)。
Add "Qt Versions", "add" add qmake, select the front compiled qmake (/ usr / local / bin / qmake).

添加“Kits”,“add”添加一个Kit,自己命名,然后选择“Compiler”和“Qt Version”,这两个是选择上两步添加的“Compiler”和“Qt Version”。
Add "Kits", "add" Add a Kit, name it yourself, then select "Compiler" and "Qt Version", which are the "Compiler" and "Qt Version" that you selected in the two steps above.

  最后“OK”退出。(Finally “Ok” Esc)

Qt应用程序创建(Qt application created)

1 菜单栏(menu): File->New File or Project。

2 Application -> Qt Widgets Application。

3 输入项目名字,选择创建路径,下一步。
Enter the project name, choose to created path, next step

4 kit的选择,选择2.4.1中添加的Kit;下一步。
kit selection, select the Kit added in 2.4.1; next step.

5 输入类的名字,这里用默认,“Base class”选择QWidget,下一步。
Enter the name of the class, here with the default, "Base class" to select QWidget, next step

6 Finish。 =

7 Forms下有个ui文件,双击打开它。
Forms have a ui file, double-click to open it.

8 在左边栏里 Display Widgets 下有个 Label,用鼠标拖到设计界面上去,然后双击label,输入“hello world !”。
There is a label in the left column under the Display Widgets, drag the mouse to the design interface, and then double-click the label, type "hello world!".

9 编译,点击左下角的锤子形状的按钮编译,编译完成会在创建目录生成可执行文件,把它放到开发板上就可以运行了。
Compile, click the lower left corner of the hammer shape button to compile, compile will be created in the directory to create an executable file, put it on the development board can run.
</div>