在安装qt时如果用了sudo 会安装在/opt下 没用会在 ~/下 即/home/(用户名)下 请自行替换
1.方法1
/etc/profile中添加
export PATH="/opt/Qt5.14.0/Tools/QtCreator/bin:$PATH"
export PATH="/opt/Qt5.14.0/5.14.0/gcc_64/bin:$PATH"
export LD_LIBRARY_PATH="/opt/Qt5.14.0/5.14.0/gcc_64/lib:$LD_LIBRARY_PATH"
export QT_PLUGIN_PATH="/opt/Qt5.14.0/5.14.0/gcc_64/plugins:$QT_PLUGIN_PATH"
export QML2_IMPORT_PATH="/opt/Qt5.14.0/5.14.0/gcc_64/qml:$QML2_IMPORT_PATH"
source /etc/profile
此时输入 qmake -v可得到正确版本信息,与你安装的版本是一致的,如果版本低说明是Ubuntu自带的,你环境变量没有配置成功
QMake version 3.1
Using Qt version 5.14.0 in /opt/Qt5.14.0/5.14.0/gcc_64/lib
但是这样source是一次性的,每次开机都要输一次
于是在~/.bashrc添加
source /etc/profile
就不用每次都输了
2.方法2
在~/.bashrc添加