http://blog.chinaunix.net/uid-26119896-id-3141782.html
一、Qt4.6.3编译与移植到PXA270
环境:虚拟机Fedora7(建议安装Vmware Tools,详细安装方法参照Vmware帮助文档),USB串口,超级终端。
软件准备:
1、用于 Linux/X11 32位 的 Qt Creator 1.3.1 二进制软件包qt-creator-linux-x86-opensource-1.3.1.bin。
2、用于嵌入式 Linux 的 Qt 库 4.6.3包qt-everywhere-opensource-src-4.6.3.tar.gz。
1.1 编译
将 qt-everywhere-opensource-src-4.6.3.tar.gz 压缩包解压为3份,分别编译 PC ,嵌入式 x86 和 arm 三个版本。
在root目录下建立tmp文件夹,将qt-everywhere-opensource-src-4.6.2.tar.gz直接解压后复制3份,分别命名为pc、x86、arm。
1.1.1编译 PC 版
进入pc目录,执行如下操作:
#./configure
# gmake
# gmake install
安装过程比较长,没有碰到过错误。
1.1.2编译嵌入式x86版
进入x86目录,执行如下操作:
# ./configure -embedded x86 -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb
# gmake
# gmake install
安装过程比较长,没有碰到过错误。
编译安装PC版中的 qvfb:
进入pc/tools/qvfb/目录,执行如下操作:
#make
编译完毕,将pc/bin目录下的qvfb文件复制到/usr/local/Trolltech/QtEmbedded-4.6.3/bin目录。
1.1.3编译嵌入式arm版(需要 arm-linux-gcc 的支持)
1、把编译器路径加入系统环境变量,运行命令:
#gedit /root/.bashrc
2、编辑/root/.bashrc文件,在最后一行加上 export PATH=/usr/local/arm/3.4.1/bin:/$PATH
3、配置
必须加上“-prefix /usr/local/Trolltech/QtEmbedded-4.6.3-arm ”参数, 不然安装后不在QtEmbedded-4.6.3-arm文件夹下,而是覆盖了QtEmbedded-4.6.3。
# ./configure \
-prefix /usr/local/Trolltech/QtEmbedded-4.6.3-arm \
-opensource \
-confirm-license \
-release -shared \
-embedded arm \
-xplatform qws/linux-arm-g++ \
-depths 16,18,24 \
-fast \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-little-endian -host-little-endian \
-no-qt3support \
-no-libtiff -no-libmng \
-no-opengl \
-no-mmx -no-sse -no-sse2 \
-no-3dnow \
-no-openssl \
-no-webkit \
-no-qvfb \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-glib \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-nomake examples -nomake tools -nomake docs \
下面的和上面的相同
./configure -prefix /usr/local/Trolltech/QtEmbedded-4.8.6-arm -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++ -depths 16,18,24 -fast -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-webkit -no-qvfb -no-phonon -no-nis -no-opengl -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs
鼠标和触摸:
-qt-mouse-pc -qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib加上鼠标和触摸支持编译出现:
编译之后出现:
编译QT时出现lib/libQtGui.so: undefined reference to`ts_read_raw'的解决办法 – luxiaolai
http://www.th7.cn/Program/delphi/201405/207402.shtml
lib/libQtGui.so: undefined reference to`ts_read_raw'
/lib/libQtGui.so: undefined reference to`ts_open'
/lib/libQtGui.so: undefined reference to`ts_fd'
/lib/libQtGui.so: undefined reference to`ts_config'
/lib/libQtGui.so: undefined reference to`ts_close'
/lib/libQtGui.so: undefined reference to`ts_read
解决办法:
'修改qt-everywhere-opensource-src-4.7.2/mkspecs/qws/linux-arm-g++/qmake.conf文件(添加lts参数):
QMAKE_CC = arm-linux-gcc -lts
QMAKE_CXX = arm-linux-g++ -lts
QMAKE_LINK = arm-linux-g++ -lts
QMAKE_LINK_SHLIB = arm-linux-g++ -lts
4、如果放弃配置,则使用命令:# gmake confclean
编译:# gmake
安装:# gmake install
安装完成后,在/usr/local/Trolltech目录中有三个文件夹:Qt-4.6.3、QtEmbedded-4.6.3、QtEmbedded-4.6.3-arm。
1.2移植
将Fedora7上 /usr/local/Trolltech/QtEmbedded-4.6.3-arm/lib 中的所有文件复制到ARM板 /flash/qt/lib目录中;
将Fedora7上 /usr/local/Trolltech/QtEmbedded-4.6.3-arm/bin中的所有文件复制到ARM板 /flash/qt/bin目录中;
将Fedora7上 /usr/local/Trolltech/QtEmbedded-4.6.3-arm/include中的所有文件复制到ARM板 /flash/qt/include目录中;
将Fedora7上 /usr/local/Trolltech/QtEmbedded-4.6.3-arm/lib/fonts中的所有文件复制到ARM板 /flash/qt/fonts目录中;
二、Fedora7下搭建Qt Creator的ARM开发环境 2.1安装Qt-creator-1.3.1
1、把下载的qt-creator-linux-x86-opensource-1.3.1.bin文件拷到一个目录(如/root/tmp目录)2、进入目录/root/tmp
设置qt-creator-linux-x86-opensource-1.3.1.bin文件为可执行
#chmod +x qt-creator-linux-x86-opensource-1.3.1.bin
3、安装:
# ./ qt-creator-linux-x86-opensource-1.3.1.bin
启动安装界面,默认Next即可。
2.2 Qt-creator开发环境的配置
1、启动Qt-creator。
2、在Qt-creator菜单栏Tools--->Options打开Options窗口。
3、在Options界面左侧,点击Qt4--->Qt Versions右侧显示Qt Versions设置界面。
4、在Qt Versions界面中点击那个蓝色的大“╋”号图标
5、在下方Version Name,文本框内输入Qt的版本名,区分各个版本即可(如pc版取Qt4.6.3-pc、x86版取QtE4.6.3-x86、arm版取QtE4.6.3-arm)。
单击Qmake Location,右侧Browse按钮,在弹出的“Select QMake Executable”窗口中找到对应版本的qmake程序(按照我们前面安转的,
pc版路径:/usr/local/Trolltech/Qt-4.6.3/bin/qmake,
x86版路径:/usr/local/Trolltech/QtEmbedded-4.6.3/ bin/qmake,
arm版路径:/usr/local/Trolltech/QtEmbedded-4.6.3-arm/bin/qmake),单击打开,
回到Qt Versions界面,单击Debugging Helper,右侧Rebuild按钮,等待片刻,看到Debugging Helper,后出现一个绿色的“√”即可。
同理完成其他版本的添加。添加完毕,单击OK按钮关闭Options窗口。到此,Qt-creator配置完毕。
2.2 示例
从usr/local/Trolltech/QtEmbedded-4.6.3/demos下复制books例程到root/tmp文件夹下。
启动Qt-creator,File--->Open File or Project,打开root/tmp/books/books.pro。
这里分两部分,首先编译x86下的,并运行在qvfb下,再编译arm下的,移到开发板下运行。
2.2.1 x86下的编译与调试
在Qt-creator界面左侧点击Projects图标,打开工程设置界面,执行如下操作:
1、配置:
在Edit Project Settings for Project books--->Build Settings--->Edit Build Configuration;单击Add,在下拉列表中选择Using Qt Version “QtE4.6.3-x86”弹出对话框单击Ok按钮,在
Edit Build Configuration;下会出现蓝色的Make QtE4.6.3-x86 Release active.字符,单击激活
QtE4.6.3-x86 Release。
在Run Settings--->Edit run configuration:右侧单击Show Details按钮,在打开的下拉列表中Arguments,文本框中添加参数“-qws”。
设置完毕,点击Edit图标,回到编辑界面。
4、编译:
在Build菜单下,先Clean Project “books”,然后Build Project “books”,在右下角Compile Output窗口能看到编译信息(按上面这样走来,到此编译不会出问题的)。
5、运行:
启动终端,# /usr/local/Trolltech/QtEmbedded-4.6.3/bin/qvfb -width 800 -height 480 &,启动Qvfb。
6、回到Qt-creator,Build--->Run,运行程序。
切换Qvfb窗口中,是不是看到Books运行的界面了。
7、调试:
Debug--->Start Debugging--->Start Debugging,即可启动调试(请保证books路径中没有中文名,即不要把books工程放在了某个含有中文字符的文件夹下,不然无法启动调试)。
此时感觉如果前面编译选项Edit Project Settings for Project books--->Build Settings--->Edit Build Configuration:选择Debug项,则调试启动速度比Release时的要快很多。
2.2.2 arm编译并移植
1、编译:
在Projects设置界面下,选择Using Qt Version “QtE4.6.3-arm”项,余下参数不变,build。
复制编译好的文件(也许还有images文件夹)到ARM板的文件系统的某个目录下,直接把books文件夹复制过去。
2、运行及错误处理:
在minicom下面,ps一下,找到qpe进程对应的PID,比如1234,然后通过kill 1234杀死Qtopia。
进入books目录,执行./books –qws,此时就会出现前面讲到的“relocation error: /usr/local/Trolltech/QtEmbedded-4.6.3-arm/lib/libQtGui.so.4: symbol powf, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time reference”错误。
3、解决办法
进入主机/opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/lib目录下找到libstdc++.so.6链接的文件libstdc++.so.6.0.8(通过右键属性---)基本,可以看到链接的文件),复制并重命名为libstdc++.so.6到/opt/FriendlyARM/mini2440/root_qtopia/lib文件夹下,之前别忘了将该文件夹下的libstdc++.so.6移到其它地方或重命名,如libstdc++.so.6.old。
然后再运行./books –qws,看问题是不是解决了!
由于系统原因,今天要重新编译QT,在编译PC版的qvfb的make步骤时,出现了如下错误:
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriter::QAnimationWriter(QString const&, char const*)':
qanimationwriter.cpp:(.text+0xbf): undefined reference to `png_create_write_struct'
qanimationwriter.cpp:(.text+0xca): undefined reference to `png_create_info_struct'
qanimationwriter.cpp:(.text+0xe0): undefined reference to `png_set_compression_level'
qanimationwriter.cpp:(.text+0xff): undefined reference to `png_set_write_fn'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::write(png_struct_def*, unsigned char*, unsigned int)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG5writeEP14png_struct_defPhj[QAnimationWriterMNG::write(png_struct_def*, unsigned char*, unsigned int)]+0xb): undefined reference to `png_get_io_ptr'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x65): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x78): undefined reference to `png_set_sig_bytes'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0xda): undefined reference to `png_set_IHDR'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0xec): undefined reference to `png_write_info'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x107): undefined reference to `png_set_bgr'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x154): undefined reference to `png_write_image'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x172): undefined reference to `png_write_end'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x184): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1a8): undefined reference to `png_create_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1b3): undefined reference to `png_create_info_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1c9): undefined reference to `png_set_compression_level'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1e8): undefined reference to `png_set_write_fn'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x21f): undefined reference to `png_set_filler'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::~QAnimationWriterMNG()':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0x9e): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0xb0): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0x176): undefined reference to `png_write_chunk'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::setImage(QImage const&)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG8setImageERK6QImage[QAnimationWriterMNG::setImage(QImage const&)]+0xc3): undefined reference to `png_write_chunk'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::~QAnimationWriterMNG()':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0x9e): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0xb0): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0x16e): undefined reference to `png_write_chunk'
collect2: ld 返回 1
make: *** [../../bin/qvfb] 错误 1
截图如下:
解决办法:
第一步:#locate libpng
我的电脑显示如下:
/lib/i386-linux-gnu/libpng12.so.0
/lib/i386-linux-gnu/libpng12.so.0.46.0
/usr/share/doc/libpng12-0
/usr/share/doc/libpng12-0/ANNOUNCE
/usr/share/doc/libpng12-0/KNOWNBUG
/usr/share/doc/libpng12-0/README.Debian
/usr/share/doc/libpng12-0/README.gz
/usr/share/doc/libpng12-0/TODO
/usr/share/doc/libpng12-0/changelog.Debian.gz
/usr/share/doc/libpng12-0/copyright
/usr/share/doc/libpng12-0/libpng-1.2.46.txt.gz
/usr/share/doc-base/libpng12
/var/lib/doc-base/documents/libpng12
/var/lib/dpkg/info/libpng12-0:i386.list
/var/lib/dpkg/info/libpng12-0:i386.md5sums
/var/lib/dpkg/info/libpng12-0:i386.postinst
/var/lib/dpkg/info/libpng12-0:i386.postrm
/var/lib/dpkg/info/libpng12-0:i386.shlibs
第二步:建立链接#ln -s /lib/i386-linux-gnu/libpng12.so.0 /lib/i386-linux-gnu/libpng.so
第三步:修改Makefile文件,#gedit Makefile(或者 #vi Makefile),在LIBS后面添加-L/lib/i386-linux-gnu -lpng这两项
重新make后,成功!
qt程序在开发板上字体太小:
tiny6410 中 QT程序 在开发板运行字体变得很小
在 setqt4env 脚本中 第12行
export QWS_DISPLAY=:1
改为:
export QWS_DISPLAY="LinuxFb:mmWidth160:mmHeight90:1"
问题解决
如果你已经运行过错误的 setqt4env 脚本。 那么你必须直接在console中直接
export QWS_DISPLAY="LinuxFb:mmWidth160:mmHeight90:1"
可以在/etc/profile中添加这句话,没有这个文件的话可以自己建一个
qt出现问题集合:
http://blog.sina.com.cn/s/blog_6410b69201014mzk.html
QWS_MOUSE_PROTO设置问题参考:
http://www.tuicool.com/articles/I3QNz2
export QWS_MOUSE_PROTO="tslib:/dev/input/touchscreen0 mouseman:/dev/input/mouse0" ----"鼠标"类型
最终的/etc/profile和鼠标触摸和校准的部分:
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/touchscreen-1wire
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
export PATH=$PATH:$TSLIB_ROOT/bin
#export QWS_MOUSE_PROTO=MouseMan:/dev/input/mouse0;
#export QWS_MOUSE_PROTO=Tslib:/dev/touchscreen-1wire:$QWS_MOUSE_PROTO
#export QWS_MOUSE_PROTO=Tslib:/dev/input/event0
export QWS_MOUSE_PROTO="tslib:/dev/touchscreen-1wire mouseman:/dev/input/mouse0"
触摸和校准都管用