您的位置:首页 > 产品设计 > UI/UE

Building and setting up QT environment for BeagleBone

2014-03-20 10:25 1056 查看
There are too few information available on how to easily setup QT environment for building Beaglebone applications (command line or GUI). In this tutorial we will compile QT and setup the environment from scratch.

1. My environment

Host: Ubuntu 12.10 32bit (VMplayer)

Target: BeagleBone Black running Angstrom

QT: 4.8.5

2. Setup Angstrom cross-compile toolchain for Linux

Download angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2 for 64bit host or angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2 for x86 (or download more recent version at http://www.angstrom-distribution.org/toolchains/). (The Angstrom website is down for 3 weeks – meanwhile you can download the required toolchains from my gdrive –https://googledrive.com/host/0B3Z340LOBulvMG5NRmNlZEppSEE)

Run

$ tar -C / -xjf angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2


3. Download and un-tar QT

$ wget http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz $ tar -xzf qt-everywhere-opensource-src-4.8.5.tar.gz
$ mv qt-everywhere-opensource-src-4.8.5 qt-4.8.5-beagle


4. Create qmake.conf

$ cd qt-4.8.5-beagle
$ mkdir ./mkspecs/qws/linux-am335x-g++
$ cp ./mkspecs/qws/linux-arm-g++/qplatformdefs.h ./mkspecs/qws/linux-am335x-g++
$ touch ./mkspecs/qws/linux-am335x-g++/qmake.conf


Add the following to qmake.conf with your favorite editor:

#
# qmake configuration for building with arm-linux-g++
#

include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)

# modifications to g++.conf
#Toolchain

#Compiler Flags to take advantage of the ARM architecture
QMAKE_CFLAGS_RELEASE =   -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
QMAKE_CXXFLAGS_RELEASE = -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp

QMAKE_CC = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/gcc
QMAKE_CXX = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++
QMAKE_LINK = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++
QMAKE_LINK_SHLIB = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++

# modifications to linux.conf
QMAKE_AR = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/ar cqs
QMAKE_OBJCOPY = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/objcopy
QMAKE_STRIP = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/strip

load(qt_config)


5. Configure QT embedded

./configure -v -opensource -confirm-license -prefix /opt/qt -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-am335x-g++ -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast -little-endian -host-big-endian -no-pch -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-webkit -no-qt3support -nomake examples -nomake demos -nomake docs -nomake translations


  

6. Build and install

$ make -j 4
$ sudo make install


“-j 4″ will run the long build process reusing 4 CPU cores, you can change to your own CPU cores amount.

7. Install Qt SDK (lib) we built previously on your board

Make sure you beaglebone is connected to your host

ssh to your beagle (ssh root@192.168.7.2)

Create dir structure from your prefix:

root@beaglebone:/# mkdir /opt
root@beaglebone:/# mkdir /opt/qt


Copy lib from your host to beagle:

$ scp -r /opt/qt/lib root@192.168.7.2:"/opt/qt"


Add the lib directory to path by editing /etc/profile and adding:

PATH="...:/opt/qt/lib"


8. Download, install and configure QT Creator

I suggest installing QT Creator using regular installer:

Download qt-creator-linux-x86-opensource-2.8.0.run for x86 or qt-creator-linux-x86_64-opensource-2.8.0.run for 64bit

chmod +x qt-creator-linux-x86_64-opensource-2.8.0.run
./qt-creator-linux-x86_64-opensource-2.8.0.run


Follow installation Wizard

Run Angstrom toolchain environment setup:

$ . /usr/local/angstrom/arm/environment-setup


Open Qt Creator and

Configure Qt version

Go to Tools->Options->Build & Run->Qt Versions and click Add

Select qmake.conf from /opt/qt/bin

Click Ok

Configure target device connection

Go to Tools->Options->Devices

Click Add and select Generic Linux Device

Add IP 192.168.7.2, User: root

Set name to “Beaglebone”

Click Ok

Configure Compiler

Go to Tools->Options->Build & Run->Compilers and click Add->GCC

Select compiler path: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++

Click Ok

Configure Kit

Go to Tools->Options->Build & Run->Kits and click Add

Call new kit Beaglebone

Select device type: “Generic Linux Device”

Select the device you previously created

Select compiler you created

Select Qt version you created

Select GDK path as /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gdk

Click Ok

9. Build Qt application

Create new project (File->New project->Qt Project->Qt Console application)

Edit your project (.pro) file

Add the following after “TARGET=…” line:

target.files = <YOUR EXECUTABLE NAME>
target.path = /home/root
INSTALLS = target


Go to Projects -> Run, you should see on “Files to deploy” table your “target” settings

Now you are ready to build and deploy you project on your target board

The following example application should print Hello world inside your console:

#include <QCoreApplication>
#include <iostream>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

std::cout << "hello world" << std::endl;

return a.exec();
}


Good luck!

Meir Tseitlin

This entry was posted in Beaglebone, Linux Embedded, QT by Miro. Bookmark the permalink.

71 THOUGHTS ON “BUILDING AND SETTING UP QT ENVIRONMENT FOR BEAGLEBONE”

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: