Development environment Building (iv) compiling QT 5.5.1

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/deyili/article/details/51012106

Why to compile Qt. Installs with Atp-get install 5.2.1, if there is no need for a higher QT version, this step and next steps can be skipped. If you need a later version of QT, and the official QT does not provide the ARM version, it can only be compiled by itself. This tutorial is an organized compilation of the QT5.5.1 installation process.

1. Download the QT5.5.1 resource file:

Qt-everywhere-opensource-src-5.5.1.tar.gz

Can be obtained at the following URL:

Http://download.qt.io/official_releases/qt/5.5/5.5.1/single/qt-everywhere-opensource-src-5.5.1.tar.gz

Recommendation: Save the package to the SD card, and then the compilation process on the SD card, because the compiled QT, can be reused, compiling a QT will take a lot of time. Once compiled, if the next TK1 Development Board hangs, you can plug in the SD card to install QT directly, do not need to compile again, the following Qt creator is the same truth, there are resources downloaded in the previous tutorial can also be backed up to the SD card, for the next brush machine, or brush multiple machines, you can save a lot of time. Remember, if you take my advice, be sure to format the SD card, right-click on the Linux partition (ie ext3, ext4 ...), SD card Rename an appropriate name, if you want to reuse the compiled QT, do not modify the name of the SD card after compiling, because it is related to the path of compiling.

2. Unzip the file:

CD to the downloaded resource file directory, (cd/media/ubuntu/(the name of the SD card) if it is stored under the SD card. Execute the command at the terminal:

TAR-ZXVF qt-everywhere-opensource-src-5.5.1.tar.gz

3. Do not worry about compiling, there are several pits to fill:

1). Create the following environment variables:

Terminal command: VI ~/.BASHRC

Open the file and add the following code at the end:

Export Sysroot

Export pkg_config_sysroot_dir=/

exportpkg_config_libdir= $SYSROOT/usr/lib/arm-linux-gnueabihf/pkgconfig: $SYSROOT/usr/share/pkgconfig: $SYSROOT/ Usr/lib/pkgconfig

Exportpkg_config_path= $SYSROOT/usr/lib/arm-linux-gnueabihf/pkgconfig: $SYSROOT/usr/share/pkgconfig: $SYSROOT/usr /lib/pkgconfig

Save the file and execute the command at the terminal: SOURCE~/.BASHRC

2). CD to qt-everywhere-opensource-src-5.5.1 folder, vi Open and modify file qtbase/mkspecs/linux-arm-gnueabi-g++/ qmake.conf, replace the full text as follows, remember to replace the full text:

########################################################

Makefile_generator = UNIX

CONFIG + = Incremental

Qmake_incremental_style = Sublib

Qmake_cflags_release + =-o2-march=armv7-a

Qmake_cxxflags_release + =-o2-march=armv7-a

Include (.. /common/linux.conf)

Include (.. /common/gcc-base-unix.conf)

Include (.. /common/g++-unix.conf)


# Modifications to G++.conf

QMAKE_CC = gcc

Qmake_cxx = g++

Qmake_link = g++

Qmake_link_shlib = g++

# Modifications to Linux.conf

Qmake_ar = AR CQS

Qmake_objcopy = Objcopy

QMAKE_NM = Nm-p

Qmake_strip = STRIP

Load (qt_config)

################################################

3). Open the qt-everywhere-opensource-src-5.5.1 folder under Qt.pro, you will send many addmodule (...), comment out Qtcanvas3d, Qt3d, Qtconnectivity, Qtwayland These modules, that is, using the # comment out the addmodule (...) containing the above fields.

4). If you want to use the camera, video playback and other multimedia features, be sure to install the Gstreamer/libgstreamer, can be installed through Apt-get.

Execute command in terminal: sudo apt-get install gstreamer1.0

5). Execute the command in the terminal:

./configure-release-opensource-xplatform LINUX-ARM-GNUEABI-G++-PREFIX/OPT/QT551-NO-C++11-QT-ZLIB-QT-XCB

Note:/opt/qt551 is the installation directory for QT configuration and can be set by itself. -qt-zlib and-QT-XCB is the third-party library compiled into QT, this tutorial only select the Zlib and XCB library, it is recommended to determine in advance whether additional third-party libraries, to avoid later because of the lack of libraries, and recompile QT, this is a very painful thing.

The following is an excerpt of the official QT documentation:

Third-party Libraries

THEQT source packages include third-party libraries. To set whether Qt should usethe system's versions of the libraries or to use the bundled version, Passeither-system Or-q Tbefore the name of the library to configure.

Thetable below summarizes the Third-party options:

Library Name

Bundled in Qt

installed in System

Zlib

-qt-zlib

-system-zlib

Libjpeg

-qt-libjpeg

-system-libjpeg

Libpng

-qt-libpng

-system-libpng

xCB

-qt-xcb

-system-xcb

Xkbcommon

-qt-xkbcommon

-system-xkbcommon

FreeType

-qt-freetype

-system-freetype

PCRE

-qt-pcre

-system-pcre

Harfbuzz-ng

-qt-harfbuzz

-system-harfbuzz

     









4. Compile and install:

Execute command in terminal: Make

It will take some time. If the compilation is successful, the following installation steps are possible.

Here again, if you choose to do the above in the SD card, then congratulations, if the next time you need to install QT, the above to compile QT process This can skip all, only need to CD to the directory, perform the following installation.

Execute command in terminal: sudo make install

After a long wait, QT compiles successfully. You can view the CD to/opt/qt551 (the installation directory for this tutorial) to be sure.

 

5. Configure Environment variables:

Execute command in Terminal: VI ~/.BASHRC Open file, add the following at the end of the file:

Export Path=/opt/qt551/bin: $PATH

Export Ld_library_path=/opt/qt551/lib: $LD _library_path

Remember:/opt/qt551 is the directory installed in this tutorial, if you have customized your own installation directory, please make the appropriate changes. Note: Place the path in front of $path and $ld_library_path so that the system finds the qt5.5.1 library first, because the system comes with a lower version of Qt.

Save the file to exit.

Execute command on terminal: source ~/.BASHRC

6. Verify that QT is installed successfully:

Terminal Execution Command qmake-version

If the version of QT is 5.5.1, the installation is successful.

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.