[Solved] Trouble with QMake using wrong version of Qt

• Jan 17, 2023 - 02:01

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

Do you still have an unanswered question? Please log in first to post your question.