Construction of Qt environment under Linux system

http://www.linuxidc.com/Linux/2013-07/87576.htm


a. Install the G++ environment
sudo apt-get install build-essential
and some other related environments. If not installed, 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 libxrandr-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 After
decompression, 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)
and a dialog box appears below to select open source edition. This is the free edition. Enter yes to accept the agreement.
(1) If the various library files of your machine are complete, after a while, the configuration is completed, the following message will appear
              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'
It means that the Makefile is successfully generated
(2) If the following message 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++
        is still the old way, with the same change. Enter config.test/x11/xlib and execute the make command, see the error message
        g++ -Wl,-O1 -o xlib xlib.o -L/usr/X11R6/lib -lXext -lX11 -lm
        /usr/bin/ld: cannot find -lXext
        See, g++ is under /usr/X11R6/lib, but libXext.so cannot be found.
        The reason is that the development package of libX11 needs to be installed. In Ubuntu/debian, the package name is libX11-dev
        . According to past experience, the following three packages are installed before ./configure, basically everything is fine.
        sudo apt-get install libX11-dev libXext-dev libXtst-dev
After installing the required package, re-./configure can generate the Makefile file.


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

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

When gold is installed In the linker system, the compile script will add the -fuse-ld=gold option, but this option is not supported by gcc. The solution is to remove this option, find the file src/3rdparty/webkit/Source/common.pri, and block QMAKE_LFLAGS+=-fuse-ld=gold.

#
QMAKE_LFLAGS+=-fuse-ld=gold 4. It takes 2 hours to

compile QT and execute the make command. 5. Install QT and run the sudo make install command. It takes a few minutes, and it is installed to /usr/local/Qt-4.8.2 by default. Run /usr/local/Qt-4.5.3/bin/designer, if QT can be started, it means that QT has been installed. Sixth, set the environment variable Change the user environment variable 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 to include root Add the environment variable
sudo gedit /etc/profile (here the profile file needs to change the permissions to write)
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
7. Test environment variables
Restart test environment variables:
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
displays installation location information:
/usr/local/Trolltech/Qt-4.8.2/bin/qmake
environment variable is set successfully.


Code:
If you need 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, only specific connections can be made after -l A certain library file, and if the file is "libxxx.so", only "xxx" is connected after -l.

Recommended reading:

Create a desktop startup icon for the newly installed Qt Creator under Linux http://www.linuxidc.com/Linux/2012-08/67214.htm

Install QT Creator 2.5.0 on Ubuntu 11.04 http://www.linuxidc .com/Linux/2012-06/62607.htm

Qt creator for PlayBook installation processhttp://www.linuxidc.com/Linux/2012-05/60652.htm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326314807&siteId=291194637