Search Suggest

Build QT everywhere cho board nhúng FriendlyARM Mini2440



1. Download source code
https://download.qt.io/archive/qt/
Tất cả các version được đặt ở link trên, bạn có thể dùng các version qt-everywhere-opensource-src-4.7.2.tar.gzqt-everywhere-opensource-src-4.8.5.tar.gzqt-everywhere-opensource-src-5.3.2.tar.gz.
Ở các version 5 trở lên có một sự thay đổi lớn so với các version 4 trở xuống, trong bài viết này sử dụng qt-everywhere-opensource-src-4.7.2.tar.gz làm ví dụ.

2. Build QT Everywhere
- Build tslib-1.0

- Giải nén qt-everywhere-opensource-src-4.7.2.tar.gz bằng chuột hoặc bằng lệnh
$ tar xf qt-everywhere-opensource-src-4.7.2.tar.gz  

- Di chuyển terminal vào thư mục source vừa giải nén
- Mở file qt-everywhere-opensource-src-4.7.2/mkspecs/qws/linux-arm-g++/qmake.conf và modify:
 #  
# qmake configuration for building with arm-linux-g++
#
include(../../common/g++.conf)
include(../../common/linux.conf)
include(../../common/qws.conf)

# modifications to g++.conf
QMAKE_CC = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-gcc
QMAKE_CXX = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++

# modifications to linux.conf
QMAKE_AR = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-objcopy
QMAKE_STRIP = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-strip

load(qt_config)

- Configure
 ./configure --prefix=/friendlyarm -embedded arm -xplatform qws/linux-arm-g++ \  
-qt-mouse-tslib -little-endian -no-webkit -no-qt3support -no-cups -no-largefile \
-optimized-qmake -no-openssl -nomake tools -qt-sql-sqlite -no-3dnow -system-zlib \
-qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-opengl -gtkstyle -no-openvg \
-no-xshape -no-xsync -no-xrandr -qt-freetype -qt-gfx-linuxfb -qt-kbd-tty \
-qt-kbd-linuxinput -qt-mouse-tslib -qt-mouse-linuxinput

Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition. Chọn o

...

Type '3' to view the GNU General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.

Do you accept the terms of either license? Chọn yes  

- Compile
 make  
make install



Sau khi build xong sẽ được thư mục như trên:
- bin : thư mục chứa chương trình qmake, dùng để tạo Makefile để build các qt application cho board
- lib : thư mục tất cả các thư viện qt, chúng ta sẽ copy thư mục này xuống board để dùng
        ngoài ra còn có thư mục con là fonts để dùng cho qt


3. Ví dụ
Chúng ta sẽ chạy các ứng dụng được build sẵn trong thư mục examples như trong hình trên.

Để chạy được app dưới board có hai cách:
- Copy qt xuống sdcard
- Dùng NFS

3.1 sdcard
- format FAT32
- copy thư mục lib và examples vào một thư mục nào đó dưới sdcard, vd <sdcard>/qte
- gắn sdcard vào board
- sdcard sẽ được tự đọng mount vào thư mục /sdcard , có thể dùng lệnh cat /sdcard để xem
- setup biến môi trường để chạy app

 DEPEND_LIB_DIR=/sdcard/qte  
export PKG_CONFIG_PATH=${DEPEND_LIB_DIR}/lib/pkgconfig
export LD_LIBRARY_PATH=${DEPEND_LIB_DIR}/lib

- chạy app
 cd /sdcard/qte/examples/widgets/analogclock  
./analogclock -qws

Note: Khi copy lib xuống sdcard format FAT32 thì sẽ mất khả năng tạo alias, có nghĩa là trong thư mục lib bạn sẽ thấy có 3 dạng của một lib như dưới
libQtGui.so.4
libQtGui.so.4.7
libQtGui.so.4.7.2

trên thực tế chỉ có libQtGui.so.4.7.2 là thực sự tồn tại, libQtGui.so.4 và libQtGui.so.4.7 là những alias của libQtGui.so.4.7.2, chính vì thế khi copy xuống sdcard bạn chỉ thấy libQtGui.so.4.7.2 mà thôi. Vì thế sau khi copy xong bạn cần thực hiện một việc là đổi tên tất cả các file dạng libQtGui.so.4.7.2 thành libQtGui.so.4

3.2 NFS
Sau khi mount xong thì làm các bước source biến môi trường và chạy app như trên sdcard



إرسال تعليق