Build a Qt environment in Linux

Source: Internet
Author: User

I. Install the G ++ Environment
Sudo apt-get install build-essential
Other related environments. Without installation, some qt components cannot be compiled normally, such as openGL.
Sudo apt-get install libx11-dev libxau-dev libxaw7-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev
Sudo apt-get install libxext-dev libxfixes-dev libxfont-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev
Sudo apt-get install libxpm-dev libxrandroid-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev
Sudo apt-get install libglib2.0-dev
Sudo apt-get install libssl-dev
Sudo apt-get install libgtk2.0-dev
Sudo apt-get install libcups2-dev
Sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
Sudo apt-get install libgstreamer0.10-dev
 
II. Decompress the code
Tar zxvf qt-everywhere-opensource-src-4.8.4.tar.gz
Decompress the package and enter the decompressed source code folder.
3. Execute./configure to generate makefile
./Configure-prefix/usr/local/Qt-4.8.2
(The directory/usr/local/Qt-4.8.2 specified above is the installation directory after make install)
In the dialog box that appears, select open source edition. This is the Free edition. Enter yes to accept the protocol.
(1) If all the database files on your machine are complete, the following information will appear after a short period of configuration.
Qt is now configured for building, just run 'make'
Once everything is built, you must run 'make install'
Qt will be installed into/usr/local/Qt-4.8.2
To reconfigure, run 'make confclean' and 'configure'
Indicates that the Makefile file is successfully generated.
(2) If the following information appears:
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in/home/gcgily/qt-everywhere-opensource-src-4.8.4/mkspecs/linux-g ++
The old method should not be changed. Run the make command in config. test/x11/xlib to check the error message.
G ++-Wl,-O1-o xlib. o-L/usr/X11R6/lib-lXext-lX11-lm
/Usr/bin/ld: cannot find-lXext
See it. in/usr/X11R6/lib, The libXext. so cannot be found in g ++.
The reason is the need to install libX11 development kit, in Ubuntu/debian package name is libX11-dev
Based on past experience, you can install the following three packages before./configure, which means everything is fine.
Sudo apt-get install libX11-dev libXext-dev libXtst-dev
Install the required package and then run the./configure command to generate the Makefile file.


If: Project ERROR: Package gstreamer-app-0.10 not found appears, execute the following command
Apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev if: g ++: error: unrecognized command line option '-fuse-ld = gold' appears'

This is a bug in Qt: https://bugs.webkit.org/show_bug.cgi? Id = 89312

In a system with a gold linker installed, the-fuse-ld = gold option is added to the compilation script, but this option is not supported by gcc. The solution is to remove this option, find the file src/3 rdparty/webkit/Source/common. pri, and shield QMAKE_LFLAGS + =-fuse-ld = gold.

#
QMAKE_LFLAGS + =-fuse-ld = gold

4. Compile QT
It takes 2 hours to execute the make command.
5. Install QT
Run the sudo make install command. It takes several minutes to install it to/usr/local/Qt-4.8.2. Run/usr/local/Qt-4.5.3/bin/designer by default. If QT can be started, it indicates that QT has been installed.
6. Set Environment Variables
Change User Environment Variables
Gedit/home/username/. bashrc
Add:
Export QTDIR =/usr/local/Qt-4.8.2
Export PATH = $ QTDIR/bin: $ PATH
Export MANPATH = $ QTDIR/man: $ MANPATH
Export LD_LIBRARY_PATH = $ QTDIR/lib: $ LD_LIBRARY_PATH
Change environment variables including root users
Sudo gedit/etc/profile (here, the profile file must change the permission before writing)
Add:
Export QTDIR =/usr/local/Qt-4.8.2
Export PATH = $ QTDIR/bin: $ PATH
Export MANPATH = $ QTDIR/man: $ MANPATH
Export LD_LIBRARY_PATH = $ QTDIR/lib: $ LD_LIBRARY_PATH
VII. Test Environment Variables
Restart the test environment variable:
Qmake-v
Display version information:
QMake version 2.01a
Using Qt version 4.8.2 in/usr/local/Qt-4.8.2/lib
Which qmake
Display the installation location information:
// Usr/local/Trolltech/Qt-4.8.2/bin/qmake
Environment Variable set successfully.


Code:
To reference other packages and library files in Qt, use:
INCLUDEPATH + =/usr/local/include/
INCLUDEPATH + =/usr/local/include/Eigen
INCLUDEPATH + =/usr/local/include/boost
INCLUDEPATH + =/usr/local/include/CGAL


LIBS + =-L/usr/local/lib/-lgmp
LIBS + =-L/usr/local/lib/-lmpfr
In the LIBS parameter,-l can only be followed by a specific library file. If the file is "libxxx. so",-l is followed by "xxx ".

Recommended reading:

Create a desktop startup icon for the installed Qt Creator in Linux

Install QT Creator 2.5.0 on Ubuntu 11.04

Qt creator for PlayBook Installation Process

Related Article

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.