[Solved] Trouble with QMake using wrong version of Qt
Hello. I am a newbie dev. I am trying to compile Musescore 4 on my Linux Mint machine. I am having trouble with QMake; it is using the wrong version of Qt.
I have downloaded Qt from https://download.qt.io/official_releases/online_installers/. I then logged into my Qt account and installed Qt 5.15.
Currently if I type qmake --version
in the console I get the output
QMake version 3.1
Using Qt version 5.9.7 in /home/my_name/anaconda3/lib
It appears that QMake is trying to use the version of Qt found in my Anaconda Python distribution, and not the one found in /opt/Qt.
I have edited the config file /usr/share/qtchooser/qt5-x86_64-linux-gnu.conf. Originally the file said
/usr/lib/qt5/bin
/usr/lib/x86_64-linux-gnu
but now I have replaced it with
/opt/Qt5/bin
/opt/Qt5/lib
Unfortunately it didn't make a difference, QMake still latches on to the Qt found in Anaconda.
Did anybody else have this issue?
To solve the issue you need to edit your PATH environmental variable. As a test you can temporarily change your PATH for your current terminal session:
export PATH=/opt/Qt/5.15.0/gcc_64/bin/:$PATH
export
will change the environmental variable PATH. PATH is a variable that tells Linux where to search when looking for an executable. Qmake was picking up the old version of Qt from the Anaconda distribution stored in my PATH variable. To fix this we need to put the new version of Qt in the PATH variable and we need to append it before the Anaconda distribution. You need to keep the rest of PATH variable intact because there are many other executables that the system needs and are stored in the PATH variable.
:$PATH
tells Linux to append the previous PATH to the end of the given /opt/Qt/5.15.0/gcc_64/bin/
directory.
/opt/Qt/5.15.0/gcc_64/bin/
is where my Qt 15.5.0 executable is stored. I know this because there is a file there named qmake
which stores the required executable for Qmake.
In the future or on your machine, Qt may be stored somewhere else. Look around in the file explorer in opt/Qt for a file called qmake
. The folder containing qmake
is the folder that you should append to PATH. Look for key folders such as gcc (short for GNU Compiler Collection, the tool used for C++ compilation) or bin (short for binary).
To test whether the change worked, in the terminal type which qmake
and qmake --version
to make sure that qmake is using the correct directory and version of Qt.
If which
gives you "command not found" then you have replaced, not appended, your PATH with /opt/..., you need to append to the beginning of :$PATH and not replace it completely. Start a new terminal window and try again.
Once you have a successful test, cd into your home folder and edit the .profile
file. At the end of the file make a new line; there paste the successful PATH changing code (which for me was export PATH=/opt/Qt/5.15.0/gcc_64/bin/:$PATH
).
Comments
What your $PATH ?
In reply to What your $PATH ? by Jojo-Schmitz
/home/my_name/anaconda3/bin:/home/my_name/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
In reply to /home/my_name/anaconda3/bin:… by 7xpmfcktmt
/opt/Qt5/bin and /opt/Qt5/lib are not in PATH, so not found.
In reply to /home/my_name/anaconda3/bin:… by 7xpmfcktmt
Then again /usr/lib/qt5/bin and /usr/lib/x86_64-linux-gnu aren't either...
What does
which gmake
say?In reply to Then again /usr/lib/qt5/bin… by Jojo-Schmitz
entering
which gmake
gives me no response, not even an error.which make
gives me/usr/bin/make
In reply to entering which gmake gives… by 7xpmfcktmt
Outch, I of course meant
which qmake
In reply to Outch, I of course meant… by Jojo-Schmitz
/home/my_name/anaconda3/bin/qmake
In reply to /home/my_name/anaconda3/bin… by 7xpmfcktmt
There you go!
You need to make sure /opt/Qt5/bin is in PATH and before anaconda
In reply to There you go! You need to… by Jojo-Schmitz
Thank you Jojo for your help, I have successfully changed the $PATH and now I'm using Qt 5.15.0. I am still getting compile errors though so I will mark this as solved and start a new thread.