Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. MinGW Makefile project in QtCreator
QtWS25 Last Chance

MinGW Makefile project in QtCreator

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
mingwmakefile
8 Posts 3 Posters 5.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on 24 Apr 2017, 13:56 last edited by
    #1

    I would like to edit code and build an existing Makefile project with QtCreator (I downloaded the MinGW version of Qt).
    The project I'm going to work with already has a Makefile and it compiles fine with MinGW (MSYS2) launching 'make' from a specific folder.
    As an example, but it could be any other one, please take a look to this repository:

    https://github.com/bluekitchen/btstack

    the desired Makefile is found at the following path: /port/windows-winusb/Makefile
    I created a new "Import Existing Project" in QtCreator. In the Projects / Build window I selected the folder above as "build directory". Now when I try to either make or clean the project the compiler complains about the "CORE" and "COMMON" macro. Removing them complains about a invalid invocation for include ${BTSTACK_ROOT}/example/Makefile.inc, etc...

    Does the MinGW compiler shipped along with Qt is different than the one that comes with MSYS2?

    M 1 Reply Last reply 24 Apr 2017, 15:14
    0
    • M Mark81
      24 Apr 2017, 13:56

      I would like to edit code and build an existing Makefile project with QtCreator (I downloaded the MinGW version of Qt).
      The project I'm going to work with already has a Makefile and it compiles fine with MinGW (MSYS2) launching 'make' from a specific folder.
      As an example, but it could be any other one, please take a look to this repository:

      https://github.com/bluekitchen/btstack

      the desired Makefile is found at the following path: /port/windows-winusb/Makefile
      I created a new "Import Existing Project" in QtCreator. In the Projects / Build window I selected the folder above as "build directory". Now when I try to either make or clean the project the compiler complains about the "CORE" and "COMMON" macro. Removing them complains about a invalid invocation for include ${BTSTACK_ROOT}/example/Makefile.inc, etc...

      Does the MinGW compiler shipped along with Qt is different than the one that comes with MSYS2?

      M Offline
      M Offline
      Mark81
      wrote on 24 Apr 2017, 15:14 last edited by
      #2

      @Mark81 The problem was the first value in the PATH variable that led to use another compiler. I think QtCreator should not rely on that variable to invoke the compiler selected in the Tools > Kit window

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 24 Apr 2017, 22:15 last edited by
        #3

        Hi,

        In that case, where should Qt Creator look for when starting the compiler ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply 25 Apr 2017, 08:04
        0
        • J Offline
          J Offline
          JKSH
          Moderators
          wrote on 25 Apr 2017, 07:06 last edited by
          #4

          Hi @Mark81,

          By default, Qt Creator uses your global system environment (including your global PATH) when compiling. There is no way to tell it to ignore a particular item in the PATH.

          If you want Qt Creator to avoid using a particular toolchain, then the best thing to do is to remove it from the global PATH. In general, if you want to use multiple versions of a toolchain on your machine, it is best not to put any of them in the global PATH.


          After you remove MSYS2 from your PATH, if you want to use it outside of Qt Creator, you can temporarily add it to the non-global environment before compiling.

          For example, add this to a batch file called setenvironment.bat: path = %path%;C:\MSYS2\MinGW\bin\ (replace "C:\MSYS2\MinGW" with your actual folder). Then, run the batch file before you compile:

          D:\MyProject\src> setenvironment.bat
          D:\MyProject\src> make
          D:\MyProject\src> make install
          

          Alternatively, you can tell Qt Creator to ignore the system environment.

          Open your project in Qt Creator, and open Projects Mode (Ctrl + 5). Under "Build Environment", check "Clear system environment". Note, you will need to do this for every kit in every project.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          M 1 Reply Last reply 25 Apr 2017, 08:07
          1
          • S SGaist
            24 Apr 2017, 22:15

            Hi,

            In that case, where should Qt Creator look for when starting the compiler ?

            M Offline
            M Offline
            Mark81
            wrote on 25 Apr 2017, 08:04 last edited by
            #5

            @SGaist said in MinGW Makefile project in QtCreator:

            In that case, where should Qt Creator look for when starting the compiler ?

            In the folder where the compiler is placed, of course :)
            Tools > options > build&run > compilers: here there are the full (absolute) paths.

            1 Reply Last reply
            0
            • J JKSH
              25 Apr 2017, 07:06

              Hi @Mark81,

              By default, Qt Creator uses your global system environment (including your global PATH) when compiling. There is no way to tell it to ignore a particular item in the PATH.

              If you want Qt Creator to avoid using a particular toolchain, then the best thing to do is to remove it from the global PATH. In general, if you want to use multiple versions of a toolchain on your machine, it is best not to put any of them in the global PATH.


              After you remove MSYS2 from your PATH, if you want to use it outside of Qt Creator, you can temporarily add it to the non-global environment before compiling.

              For example, add this to a batch file called setenvironment.bat: path = %path%;C:\MSYS2\MinGW\bin\ (replace "C:\MSYS2\MinGW" with your actual folder). Then, run the batch file before you compile:

              D:\MyProject\src> setenvironment.bat
              D:\MyProject\src> make
              D:\MyProject\src> make install
              

              Alternatively, you can tell Qt Creator to ignore the system environment.

              Open your project in Qt Creator, and open Projects Mode (Ctrl + 5). Under "Build Environment", check "Clear system environment". Note, you will need to do this for every kit in every project.

              M Offline
              M Offline
              Mark81
              wrote on 25 Apr 2017, 08:07 last edited by
              #6

              @JKSH said in MinGW Makefile project in QtCreator:

              By default, Qt Creator uses your global system environment (including your global PATH) when compiling. There is no way to tell it to ignore a particular item in the PATH.

              Thanks for the clarification.
              As said to SGaist, I don't understand why it cannot use the compiler's path instead of rely on env vars...

              J 1 Reply Last reply 25 Apr 2017, 08:27
              0
              • M Mark81
                25 Apr 2017, 08:07

                @JKSH said in MinGW Makefile project in QtCreator:

                By default, Qt Creator uses your global system environment (including your global PATH) when compiling. There is no way to tell it to ignore a particular item in the PATH.

                Thanks for the clarification.
                As said to SGaist, I don't understand why it cannot use the compiler's path instead of rely on env vars...

                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 25 Apr 2017, 08:27 last edited by
                #7

                @Mark81 said in MinGW Makefile project in QtCreator:

                Thanks for the clarification.
                As said to SGaist, I don't understand why it cannot use the compiler's path instead of rely on env vars...

                You're welcome.

                Qt Creator does not call the compiler directly. It simply calls mingw32-make.exe and tells it which Makefile to use.

                mingw32-make.exe is the one that calls the compiler (g++.exe). The Makefile does not contain the absolute path to the compiler, so it searches your system environment to find g++.exe.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                M 1 Reply Last reply 25 Apr 2017, 08:34
                1
                • J JKSH
                  25 Apr 2017, 08:27

                  @Mark81 said in MinGW Makefile project in QtCreator:

                  Thanks for the clarification.
                  As said to SGaist, I don't understand why it cannot use the compiler's path instead of rely on env vars...

                  You're welcome.

                  Qt Creator does not call the compiler directly. It simply calls mingw32-make.exe and tells it which Makefile to use.

                  mingw32-make.exe is the one that calls the compiler (g++.exe). The Makefile does not contain the absolute path to the compiler, so it searches your system environment to find g++.exe.

                  M Offline
                  M Offline
                  Mark81
                  wrote on 25 Apr 2017, 08:34 last edited by
                  #8

                  @JKSH said in MinGW Makefile project in QtCreator:

                  Qt Creator does not call the compiler directly. It simply calls mingw32-make.exe and tells it which Makefile to use.

                  mingw32-make.exe is the one that calls the compiler (g++.exe). The Makefile does not contain the absolute path to the compiler, so it searches your system environment to find g++.exe.

                  Ah ok, it makes sense.
                  So far, the only way might be QtCreator should add to the sys env of the shell the path of the selected compiler. But perhaps they rely on the knowledge of the users :)

                  1 Reply Last reply
                  0

                  1/8

                  24 Apr 2017, 13:56

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved