Setting up QT Cross-compiling environment in virtual machine under Ubuntu14.04--2014/8/14

Source: Internet
Author: User
Tags windows download automake

First, Ubuntu installation and configuration

On Windows download VMware10.0.2 and install, find permanent key activation online. After opening is the Chinese version
Download ubuntu-14.04.1-desktop-i386 on the Ubuntu official web site

Open the virtual machine and create a new virtual machine, memory 1g, hard disk 20g. Virtual disk files are divided into multiple saves. Open the rear card.

Virtual Machine Network mode selection bridge, because the network settings temporarily did not get, simple even campus network.
In the software update try to find the add-in driver in the graphics driver, to see if the system is not too card. found no additional drivers.
Add a software source to the software update and set up the server as a Chinese server.

Update the language in the language support of the system and add Chinese (Jane) and apply it to the whole system, and after reboot, Ubuntu becomes Chinese.

Set login interface to add root login:

Open Terminal
Enter sudo gedit/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
In the pop-up edit box enter: Greeter-show-manual-login=true save close.
And then enter in the midrange: sudo passwd root
Enter the password you want, shutdown restart in the Multiple login box to enter root and your password is good.


Second, install Qtcreater

On QT website Download qt-linux-opensource-5.2.1-x86-offline.run
After you go to the virtual machine via Mac, cut to/home/zl

In terminal execution:./qt-linux-opensource-5.2.1-x86-offline.run

The graphical interface appears continuously next installed in the user directory, source build temporarily not installed

After finish opens the QT creater routine runs, appears: "Qt Creator need to set up a compiler to build." Set up a compiler in the build Suite option. ”。 It appears to be a compiler problem.

Then install the g++ compiler sudo apt-get install g++


After you install the compiler, reopen Qt Creator and find that you are ready to compile, but report an error: "Gl/gl.h:no such file or directory." This is because the machine does not have an OpenGL library installed, execute the following statement installation:

sudo apt-get install Mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev Freeglut3-dev

Once the installation is complete, compile the run again and discover that the sample program is running successfully:

In some cases, we want to write QT code in the terminal (Shell), rather than in Qt Creator, the following steps illustrate the work that needs to be done in this case:
sudo gedit ~/.BASHRC

At the end of the file plus export path= "/home/zl/qt5.3.1/5.3/gcc/bin": $PATH


Make it effective immediately and execute at the terminal:
SOURCE ~/.BASHRC

Third, the installation of the cross-compiler

1. Create a catalogue
$ sudo mkdir/usr/local/arm
2. Copy files
File arm-linux-gcc-4.4.3.tar.gz, put in desktop
Enter desktop
$ CD ~/desktop
Copy
$ sudo cp arm-linux-gcc-4.4.3.tar.gz/usr/local/arm
3. Extract Files
Enter directory
$ cd/usr/local/arm
Extract
$ sudo tar-xzvf arm-linux-gcc-4.4.3.tar.gz
4. Add Environment variables
Open the file with Gedit BASH.BASHRC
$ sudo gedit/etc/bash.bashrc
Add "Export Path=/usr/local/arm/opt/friendlyarm/toolschain/4.4.3/bin: $PATH" on the last line to save the file
Make it effective immediately and execute at the terminal:
SOURCE ~/.BASHRC

View version number, if any, successful
$ arm-linux-gcc-v


Four, the Installation Touch screen Check tool

Put the tslib-1.4.tar.gz in a directory, such as the/OPT directory. The following commands are then executed:
#tar ZXVF tslib-1.4.tar.gz
Execute the Command CD tslib, enter the Tslib current directory, and execute the following command:
#./autogen.sh

Error occurred:
./autogen.sh:4: Autoreconf:not found
is to perform autogen.sh generation under different versions of Tslib. They produce the same reasons that are
Because there is no installation
Automake tools, use the following command to install the good.
sudo apt-get install autoconf automake libtool

Continue/autogen.sh after installation
Then execute the configuration command:
#./configure--prefix=/usr/local/tslib--host=arm-linux Ac_cv_func_malloc_0_nonnull=yes
The final compilation command and installation commands are as follows:
1. Make
2. Make install


V. Compiling QT


The source code qt-everywhere-opensource-src-4.8.6.tar.gz for decompression, and copy three copies to the/usr/local directory, and named Qt-pc,qt-x86,qt-arm respectively.

1. Compile PC version


Go to the QT-PC directory and do the following:
#./configure
# make
# make Install

After completing enter Usr/local/trolltech to see if there are QT-4.8.6

modifying environment variables
Run
# gedit ~/.profile
To the last line, copy code export qtdir=/usr/local/trolltech/qt-4.8.1
Export Path=/usr/local/trolltech/qt-4.8.1/bin: $PATH
(path= $QTDIR/bin: $PATH)
Export manpath= $QTDIR/man: $MANPATH
Export ld_library_path= $QTDIR/lib: $LD _library_path
Save, exit, run
# source ~/.profile

Check for successful installation and environment variables to take effect
# Qmake–v
Show
Qmake version 2.01a
Using Qt version 4.8.1 in/usr/local/trolltech/qt-4.8.1/lib

To compile the X86 version of the installation file for the next step

sudo apt-get install Libx11-dev libxext-dev libxtst-dev Libqt4-dev

2. Compile x86 version

Go to the Qt-x86 directory and do the following:
#./configure-embedded X86-QT-GFX-QVFB-QT-KBD-QVFB-QT-MOUSE-QVFB
# make
# make Install
The installation process is relatively long and no errors have been encountered.
To compile the QVFB in the Install PC version:
Go to the qt-pc/tools/qvfb/directory and do the following:
#make

appear undefined reference to ' png_write_chunk ' etc
COLLECT2:LD return 1
Make: * * * * [...] /.. /BIN/QVFB] Error 1

Solution:
The first step: #locate libpng

Step Two: Establish link #ln-s/lib/i386-linux-gnu/libpng12.so.0/lib/i386-linux-gnu/libpng.so

Step three: Modify the Makefile file, #gedit Makefile (or #vi Makefile), add-l/lib/i386-linux-gnu-lpng after Libs

After you make it again, you succeed.

After compiling, copy the Qvfb files in the Qt-pc/bin directory to the/usr/local/trolltech/qtembedded-4.8.6/bin directory.

3. Build ARM Version

Go to the Qt-arm directory and do the following:

./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-lib  Png-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-xfix Es-no-xrandr-no-xrender-no-separate-debug-info-nomake Examples-nomake Tools-nomake docs-qt-mouse-tslib-i/u Sr/local/tslib/include-l/usr/local/tslib/lib-force-pkg-config

Error occurred: Tslib test failed
Solution:

Add in the qmake.conf of/usr/local/qt-arm/mkspecs/qws/linux-arm-g++

Qmake_incdir=/usr/local/tslib/include
Qmake_libdir=/usr/local/tslib/lib

Gedit/root/.bashrc
Add to
Export Path=/usr/local/arm/opt/friendlyarm/toolschain/4.4.3/bin: $PATH
Source/root/.bashrc

Gedit/etc/profile
Add to
Export Path=/usr/local/arm/opt/friendlyarm/toolschain/4.4.3/bin: $PATH
Source/etc/profile

Re-enter a large section above configure

After configuration is complete
Make
Make install

Alternative:
(Install QTDESIGNER,QTLIGUIST,QT Assistant in Software center)


VI. Testing of QVFB

Now Terminal input command: Qvfb-width 800-height & Open virtual buffer end;
Then you can compile and run the program in Qtcreator.

Vii. porting program to ARM Development Board (not tested)


Create a/opt/folder on the developer board

Copy the Linux/opt/ts to the/opt/of the Development Board and enter./ts/etc/ts.conf Modify the second line
, remove the # and the blanks


Into the/usr/local/trolltech/qt-arm/lib
xxxxxx-d/utulinux2.6/s3c2440_recover/usr/local/trolltech/qt-arm/lib by command CP
Take the four library files on the Linux computer and their associated symbol files to the Development Board folder.
(The-D parameter also modifies the link symbol file point).
Xxxxxx

libqtcore.so.4.8.6
Libqtsql.so.4. 8.6

libqtnetwork.so.4.8.6
libqtgui.so.4.8.6
Instance:
CP libqtcore.so*-d/utulinux2.6/s3c2440_recover/usr/local/trolltech/qt-4.6.3-arm/lib/

Modify Add Development Board/etc/profile

Export Ld_library_path=/lib: $LD _library_path
Export Qtdir=/usr/local/trolltech/qt-arm
Export qpedir= $QTDIR Export t_root=/opt/ts

Export path= $T _root/bin: $PATH

Export ld_library_path= $T _root/lib: $QTDIR/lib: $LD _library_path
Export Tslib_consoledevice=none
Export tslib_fbdevice=/dev/fb0
Export Tslib_tsdevice=/dev/event0

Export tslib_plugindir= $T _root/lib/ts
Export tslib_conffile= $T _root/etc/ts.conf
Export tslib_calibfile=/etc/pointercal
Export Qws_keyboard=usb:/dev/input/event1
Export Qws_mouse_proto=tslib:/dev/event0
Export qws_display=linuxfb:mmwidth45:mmheight60:0
Export qws_size=320x240

Then Qmake–project
Qmake

Here you need to modify the makefile:
Modify the currently generated makefile
At the end of line 19, add-lts.

LIBS = $ (sublibs)-l/usr/local/trolltech/qt-4.6.3-arm/lib-lqtgui-l/opt/ts/lib-l/usr/local/trolltech/qt-4.6.3-arm/ Lib-lqtnetwork-lqtcore-lpthread–lts

Enter the Lib library under the Development Board
Cd/lib

Ln-s libstdc\+\+.so.60.0.3 libstdc\+\+.so.6

and create the/tmp/directory below the Development Board root directory

Make

When executing the executable file, add –qws to the back

FAQ:

1 before performing your own QT program, please perform/opt/ts/bin/ts_calibrate calibration touch screen, otherwise your QT program can not use touch screen, will prompt: Could not read calibration: "/etc/pointercal"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.