ubuntu 18.04 安装qt 4.7.4

1. 环境配置

apt-get install g++
apt-get install libglib2.0-dev libsm-dev libxrender libxrender-dev libfontconfig1-dev libxext-dev libgl1-mesa-dev libglu-dev xorg-dev libx11-dev libxext-dev libxexe-dev libtst-dev

2.解压编译

把qt-everywhere-opensource-src-4.7.04tar.gz解压
./configure,
make出现了如下错误

…/…/include/QtCore/…/…/src/corelib/tools/qmap.h: In instantiation of ‘T& QMap::operator[](const Key&) [with Key = int; T = inotify_event]’:
io/qfilesystemwatcher_inotify.cpp:364:33: required from here
…/…/include/QtCore/…/…/src/corelib/tools/qmap.h:531:45: error: value-initialization of incomplete type ‘char []’
node = node_create(d, update, akey, T());
^~~

这个问题是QT版本太老,而apt-get install g++装的太新了
解决方法:切换g++和gcc的版本

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo apt-get install g+±4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±4.8 20

此时如果运行g++ -v,可以看到切换成功了版本为4.8了,现在需要重新

./configure
make
make install

3.gcc g++ 版本切换

sudo update-alternatives --config gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±7 100

4.QT/QtCreator下载

http://download.qt.io/archive/

你可能感兴趣的:(QT)