Cannot run qmake in Mac Terminal

前端 未结 6 1520
日久生厌
日久生厌 2021-02-13 02:30

I\'m learning Qt for my C++ course at college. I am trying to set up the environment for my first assignment but I can\'t seem to get it right. I swear I have run qmake in the

相关标签:
6条回答
  • 2021-02-13 02:44

    It is generally not needed at all to touch the PATH on any system (Mac, Unix, Windows) merely to use Qt. You may have multiple Qt versions installed in parallel (say 4.8 from macports, 5.2, git stable, etc.).

    A way of building a Qt project on Unix is (substitute relevant paths for your setup):

    mkdir ~/build-dir
    cd ~/build-dir
    ~/Qt5.2.1/5.2.1/clang_64/bin/qmake ~/src/myproject/myproject.pro
    make -j2
    # were N in -jN is the number of CPU cores on your system
    
    0 讨论(0)
  • 2021-02-13 02:50

    If you've installed the Qt SDK then the path of qmake is not automatically included as an environment variable, so you have to do it manually. This is also true in windows. I found this weird. It should be included automatically unless there is a sensible reason behind it.

    0 讨论(0)
  • 2021-02-13 02:52

    For me, I realised that the .bashrc file was not getting autoloaded on a new terminal session after adding the qmake PATH to the file (using echo 'export PATH="$(brew --prefix qt@5.5)/bin:$PATH"' >> ~/.bashrc).

    So I simply run source ~/.bashrc and bam! It worked!

    0 讨论(0)
  • 2021-02-13 02:55

    Did you set the environment variable PATH with the path to Qt?

    in Terminal do: echo $PATH and look for something like /usr/local/Qt-5.x.x/bin:PATH

    If there is not any path to your installed qt, set it like this:

    In .profile (if your shell is bash), add the following lines:

    PATH=/usr/local/Qt-5.0.2/bin:$PATH
    export PATH
    

    To help you in the process you probably would like to read here: QT mac install

    ANSWER TO NEW QUESTION

    If writing code nothing seems to be recognized you should add the link to your include directory. The include directory is where there are all the header file, so your IDE can give you suggestion about class method etc...

    0 讨论(0)
  • 2021-02-13 02:56

    Working on 9 APR 2020 set Path echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile

    0 讨论(0)
  • 2021-02-13 03:07

    The reason why you cannot execute the program is because it's not in the $PATH of the shell you are using. First find where it is located and then add the directory to that binary directory to your $PATH environment variable. Then you'll be able to execute it in your terminal.

    For instance, if you are using ZSH and your program resides in "/opt/local/bin" then execute the following to make it available through $PATH:

    export PATH=$PATH:/opt/local/bin
    

    After this point you would be able to run the program. And you should add this to your shell RC file.

    0 讨论(0)
提交回复
热议问题