146

I have a software in ubuntu that requires me to run qmake to generate the Makefile.

However, running qmake gives back this error,

qmake: could not find a Qt installation of ''

I have installed what I thought to be the required packages using,

sudo apt-get install qt4-qmake
sudo apt-get install qt5-qmake

But the error didn't go away.

Any help on this would be gladly appreciated!

Curious
  • 5,533
  • 6
  • 33
  • 63
  • 6
    Try running `sudo apt-get install qtcreator`. It installs the full Qt SDK + an IDE. It should add everything you need. – sashoalm May 17 '13 at 10:42
  • Hi @sashoalm, thanks a lot, seems I had other packages missing. Now its working :D – Curious May 17 '13 at 11:58
  • 6
    This is not a good solution as it will install many potentially unneeded packages. – Scone Apr 24 '15 at 01:23

11 Answers11

198

sudo apt-get install qt5-default works for me.

$ aptitude show qt5-default
tells that

This package sets Qt 5 to be the default Qt version to be used when using development binaries like qmake. It provides a default configuration for qtchooser, but does not prevent alternative Qt installations from being used.

ptmono
  • 2,112
  • 2
  • 15
  • 8
  • 1
    Can you please decribe your solution more? – user35443 Sep 15 '13 at 15:47
  • 3
    the accepted answer is not an answer at all. This one should be the accepted answer. – thias Nov 13 '14 at 09:46
  • 1
    Following sets up the complete qt5 development installation for me: apt-get install qt5base-dev qtdeclarative5-dev qt5-qmake qt5-default qttools5-dev-tools And then check using: qtchooser -print-env – Salil Jan 25 '16 at 23:42
31

You could check path to qmake using which qmake.

Consider install qt4-default or qt5-default depends what version of qt you want use.

You could also use qtchooser - a wrapper used to select between Qt development binary versions.

jtomaszk
  • 5,583
  • 2
  • 26
  • 39
  • 2
    Hi @Warthel4578, thanks, your answer helped me indirectly, since I installed qt4-qmake, I should have invoked 'qt4-qmake' instead of 'qmake' (I found both of them in the directory path). Now its working :) – Curious May 17 '13 at 12:00
  • Thanks Warthel this helped me discover why my qmake wasn't working. qmake on Ubuntu 14.04 was symlinked to qtchooser – Scone Apr 24 '15 at 01:26
  • I got to this SO answer, then found, based on the next error (`no qtwebkit installation found`) that I also had to run `apt-get install qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x` as described on [the Thoughtbot Github wiki page](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#debian--ubuntu) – sameers Aug 31 '17 at 22:37
17

For others in my situation, the solution was:

qmake -qt=qt5

This was on Ubuntu 14.04 after install qt5-qmake. qmake was a symlink to qtchooser which takes the -qt argument.

Scone
  • 633
  • 6
  • 10
11

As Debian Qt's maintainer please allow me to suggest you to not use qtx-default. Please read qtchooser's man page, the solution is described there. If you are interested in packaging an app you can also take a look at this blog post I made explaining how to do it

# method 1
QT_SELECT=qt5 qmake

# method 2:
export QT_SELECT=qt5
qmake
... more qt commands here

# method 3:
make -qt5

To use Qt 4, just replace the qt5 with qt4

Update 20210202: starting from Debian 11 (bullseye) the packages qtx-default do not longer exist. Same goes for Ubuntu, but I don't know in which specific version. If you know of a package that still has the dependency (mostly non-Debian official packages) please file a bug. Same goes for Wiki pages, etc.

lisandro
  • 119
  • 2
  • 4
  • 5
    Can you explain why we shouldn't use qtx-default, please? The qtchooser manpage helps me understand what is going on, but I don't see why having a package supply a default is a problem. – Robie Basak Aug 27 '15 at 16:23
  • 2
    It would be nice if qmake-qtX was bundled under the relevant qt version. Pulling in these pieces is bit cumbersome. – Xofo Sep 23 '16 at 05:29
  • @RobieBasak sure thing: let's say you install qt5-default. Then you run a qt4 application which calls qdbus. You get qt5's qdbus, which should work but it's not warranted to do it. – lisandro Oct 17 '17 at 17:57
  • 1
    Surely that's a bug in how the qt4 application calls qdbus or in the environment the qt4 application was run in, rather than my choice to want qt5 by default from my CLI? – Robie Basak Oct 18 '17 at 14:38
  • First thing: maybe qdbus was a bad example. Let's say upstream decided to not rename Qt's underlying tools with the 4 to 5 change. So it is not possible to know beforehand which version the app will run except you have qtchooser in the middle. But qtchooser, even if it's a nice attempt, does fall short in a number of places, at least in the distro world. Ideally each app should be either be recalled after the major version *or* compatibility should be retained. – lisandro Oct 19 '17 at 17:20
8

I had this problem building jasmine-headless-webkit Ruby gem. Despite having qt4 installed, qmake (a symlink to qtchooser) insisted it didn't know about a QT installation. OTOH, it was able to list qt4 when asked directly.

This made everything better:

export QT_SELECT=qt4

qtchooser then knew to use qmake-qt4, and so on.

Barry Kelly
  • 39,856
  • 4
  • 99
  • 180
  • Perfect! I had the same problem when trying to install qBittorrent, and mine was solved with `export QT_QMAKE=/usr/bin`. Never know when those environment variables will come back to bite ya! – Alex Ryan Aug 04 '15 at 05:50
4

Search where is qmake-qt4:

which qmake-qt4

For example qmake-qt4 is in this path:

/usr/bin/qmake-qt4

Create symbolic link:

cd /usr/local/sbin/
ln -s /usr/bin/qmake-qt4 .
mv qmake-qt4 qmake

Regards

1

I have qt4 installed. I found that using the following path worked for me, despite 'which qmake' returning /usr/bin/qmake, which is just a link to qtchooser anyway.

The following path works for me, on a 64 bit system. Running from the full path of:

/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
kristianp
  • 4,574
  • 27
  • 52
  • 1
    Of all the answers this is actually the only one that remotely worked. Except I needed to use `/usr/lib/x86_64-linux-gnu/qt5/bin/qmake`. – Akito Feb 02 '20 at 17:33
1
  • Install qt using:

    sudo apt install qt5-qmake
    
  • Open ~/.bashrc file:

    vim ~/.bashrc
    
  • Added the path below to the ~/.bashrc file:

    export PATH="/opt/Qt/5.15.1/gcc_64/bin/:$PATH"
    
  • Execute/load a ~/.bashrc file in your current shell

    source ~/.bashrc`
    
  • Try now qmake by using the version command below:

    qmake --version
    
0

A symbolic link to the desired version, defined globally:

sudo ln -s /usr/bin/qmake-qt5 /usr/bin/qmake

... or per user:

sudo ln -s /usr/bin/qmake-qt5 /home/USERNAME/.local/bin/qmake

... to see if it works:

qmake --version
Martin Zeitler
  • 49,224
  • 12
  • 97
  • 156
  • how about to add a comment, why this answer was down-voted? failing to understand or to apply the solution does not exactly qualify as a valid reason ...while I'm pretty certain it works, because I have it working just like that. – Martin Zeitler Dec 17 '16 at 01:10
  • 2
    Throwing the upvote your way because I'm not an apt-get tard, and I actually build from source, and this symlink answer was the closes to getting me on track because I forgot I had aliased my 'qmake'. Thanks. – While-E Dec 13 '18 at 18:48
0

For my Qt 5.7, open QtCreator, go to Tools -> Options -> Build & Run -> Qt Versions gave me the location of qmake.

mihota
  • 155
  • 1
  • 2
  • 11
0

if assistant is run from terminal directly, it will use the default path, usually is the /usr/bin/assistant. I had similar situation, to make it work, all I had to do is to find the actual installation of my qt installation bin path, like xxx/Qt5.13.2/5.13.2/gcc_64/bin/, type xxx/Qt5.13.2/5.13.2/gcc_64/bin/assisstant directly from terminal