Ubuntu安装Qt

一、安装

 卸载旧版本Qt,找到安装目录,例如:/home/likewei/Qt5.11.2,终端输入命令进入该目录,输入命令:./MaintenanceTool   

进入图形画面卸载就行了

1.下载安装文件,如:qt-opensource-linux-x64-5.11.2.run

2.打开终端(快捷键ctrl+alt+t),使安装文件可以执行,在当前目录输入命令 sudo chmod u+x qt-opensource-linux-x64-5.11.2.run

3.可以点击qt-opensource-linux-x64-5.11.2.run 安装。

 

二、修改更新源

1.apt-get安装源替换 阿里云源,否则安装的时候会出现“破坏了软件包间的依赖关系”等等错误。

使用命令lsb_release -a 查看系统信息,可以知道当前系统codename。

不同的版本号系统安装源codename不同。

  

编辑sources.list

sudo vim /etc/apt/sources.list

用下面的文本作为内容替换sources.list内容

ubuntu 14    

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

 

ubuntu 16 

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://extras.ubuntu.com/ubuntu/ xenial main

 

 三、安装g++

1.输入命令安装g++, sudo apt-get install g++

 默认ubuntu14的gcc版本是4.8,支持c++11, 不支持c++14,安装g++ 5

 2.添加库

      sudo add-apt-repository ppa:ubuntu-toolchain-r/test 

 3 .更新库

       sudo apt-get update

 4. 安装

       sudo apt-get install gcc-5 g++-5

5.换软连接     

 sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc -f
 sudo ln -s /usr/bin/gcc-ar-5 /usr/bin/gcc-ar -f
 sudo ln -s /usr/bin/gcc-nm /usr/bin/gcc-nm -f
 sudo ln -s /usr/bin/g++-nm /usr/bin/g++-nm -f
 sudo ln -s /usr/bin/g++-ar-5 /usr/bin/g++-ar -f
 sudo ln -s /usr/bin/g++-5 /usr/bin/g++ -f

 

6.查看版本 gcc -v

 

四、安装vim

1.sudo apt-get install vim-gtk

vim编辑备忘:输入i进入插入模式,移动鼠标删除,编辑。输入esc退出当前模式,输入:进入命令模式。:w保存。

 

五、修改default.conf文件

1.输入qmake会出错:qmake:could not exec ‘/usr/lib/x86_64-linux-gnu/qt4/bin/qmake’:NO such file or directory(32位的ubuntu报的是这样的错 qmake:could not exec ‘/usr/lib/i386-linux-gnu/qt4/bin/qmake’:NO such file or directory)

修改文件:

输入 sudo vim  /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

修改前两行,根据qt安装文件路径修改成:

/home/likewei/Qt5.11.2/5.11.2/gcc_64/bin

/home/likewei/Qt5.11.2/5.11.2/gcc_64

 

 六、安装其它

1.安装libgl1-mesa-dev ,否则在编译时会出错,提示

cannot find -lGL  
collect2:error:ld returned 1  exit status 

sudo apt-get install libgl1-mesa-dev

2.安装jsoncpp:
sudo apt-get install libjsoncpp-dev


七、设置pro文件默认打开为qtcreator
1.建立软链接
sudo ln -s /home/likewei/Qt5.12.1/Tools/QtCreator/bin/qtcreator /usr/local/bin/qtcreator
如果已经建立了加参数-f,-f 建立时,将同档案名删除.
 sudo ln -s -f /home/likewei/Qt5.12.1/Tools/QtCreator/bin/qtcreator /usr/local/bin/qtcreator
2.建立qtcreator.desktop
sudo vim /usr/share/applications/qtcreator.desktop
复制以下内容,修改图标位置,可以在网上下载一个图标:         
[Desktop Entry]
Name = Qt Creator
Comment = Open qt pro file
Exec = qtcreator %U
Terminal = false
StartupNotify = true
X-MultipleArgs = false
Type = Application
Categories = Utility;
Icon = /home/likewei/图片/appimg/Qt.png

 

Icon=// 软件图标位置,可以自己选一个png图像,把png图像的绝对路径放这就可以

三、解决Qt不能输入中文注释问题

在/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so  找到libfcitxplatforminputcontextplugin.so 。把此库文件复制到

以下Qt安装文件两个目录下面。

/home/likewei/Qt5.12.1/5.12.1/gcc_64/plugins/platforminputcontexts
/home/likewei/Qt5.12.1/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts

  

    

posted @ 2018-10-09 11:08  ike_li  阅读(1814)  评论(0编辑  收藏  举报