Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Installed Qt5.10.1 in ~/Qt5.10.1; qmake from the command line gives "bash: qmake: command not found"



  • I have successfully installed Qt5.10.1 in my ~/Qt5.10.1 directory. It includes Qt Creator which works perfectly fine and builds projects perfectly but when I try to build a project from the command line I get the standard "qmake: command not found". I have installed a few versions of Qt before but have since deleted all but the one in the directory mentioned above. Any help at all on how to best deal with this (perhaps start installing all over again?) would be greatly appreciated.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    One simple thing to do: use the full path to the qmake executable. That way you ensure that you are using the exact version of Qt you want.



  • I apologize for any inconvenience I might have cause you. I am very new to Qt (I have only been using it for about a week now). When you say "use the full path to the qmake executable" - I though using qmake on the command line in Terminal would generate an executable. How could I use the full path if haven't generated the executable with a successful build?
    I entered:
    cd ~/Qt5.10.1/5.10.1/Src/qtbase/examples/qmake/tutorial
    to build a basic "app example". I have installed Qt more than once with different versions (which might be part of my problem) - the problem seems to be that qmake isn't getting registered as existing to my operating system.



  • I forgot to mention that after I cd'd to the above /tutorial directory (which includes a hello.pro file & hello.cpp & hello files) I attempted to build with the following command:
    qmake -o Makefile hello.pro
    Again, I got the standard "bash: qmake: command not found". Any help or advice would be greatly appreciated.



  • @avmac1983 said in Installed Qt5.10.1 in ~/Qt5.10.1; qmake from the command line gives "bash: qmake: command not found":

    the problem seems to be that qmake isn't getting registered as existing to my operating system

    That's right, and by design. Unless you install the official OS-supplied packages (looks like you're on a *nix distro), you won't have qmake installed in your path. However, this is not a problem, just use the full path as @SGaist suggested. That would look something like:

    cd  ~/Qt5.10.1/5.10.1/Src/qtbase/examples/qmake/tutorial
    ~/Qt5.10.1/5.10.1/gcc_64/bin/qmake
    make
    

    Cheers.


  • Qt Champions 2019

    @avmac1983 What @SGaist means is: use the whole path to qmake to call it, like:

    ~/Qt5.10.1/5.10.1/gcc_64/bin/qmake
    


  • I entered the following commands in the Terminal. First,
    cd ~/Qt5.10.1/5.10.1/Src/qtbase/examples/qmake/tutorial
    then,
    ~/Qt5.10.1/5.10.1/clang_64/bin/qmake
    and received the following error:
    Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build.
    My 'tutorial' directory contains the following:
    hello.cpp, hello.h, hello.pro, hellounix.cpp, hellowin.cpp, AND main.cpp.
    I thought I could use qmake from the command line in one of the following forms:
    ~/Qt5.10.1/5.10.1/clang_64/bin/qmake
    or
    ~/Qt5.10.1/5.10.1/clang_64/bin/qmake -o Makefile hello.pro
    but I get the following error for both:
    Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build.
    Again, I apologize for an inconvenience I have caused. Any assistance with this problem would be greatly appreciated.


  • Qt Champions 2019

    @avmac1983 Simply copy the whole example directory ("tutorial") to some other location and build it there.

    cp -r ~/Qt5.10.1/5.10.1/Src/qtbase/examples/qmake/tutorial ~/
    cd ~/tutorial
    ~/Qt5.10.1/5.10.1/clang_64/bin/qmake
    


  • Hi all.
    The simple solution is to added the qmake path to the profile file:

    > vim ~/.bashrc
    # export Qt bin path, qmake path
    export PATH="/opt/Qt/5.15.1/gcc_64/bin/:$PATH"
    > source ~/.bashrc
    

  • Lifetime Qt Champion

    Hi @said_oslo,

    I cannot recommend that. Especially if you want to use several Qt versions in parallel, the only possible way is to call qmake with it's full path.

    And if you use Qt Creator, it will already handle that for you.

    Regards


Log in to reply