<SOLVED>reconciling 2 ways of coding

I was given sage advice here not to "pollute" the path variable with references to Qt...which makes a lot of sense. I also asked given 2 compilers -- one mingw standalone vs. one that comes from the Qt package which one to use --told to use the one that comes with the Qt package. I was coding a tutorial which called to use the Qt compiler, yet I would have to use the path variable (as this tutorial suggested). Won't I be polluting the path with a qt reference? I may over over-analyzing a bit here, but I hope you see my point.

ok, I will review. Thx for the reference. In the meantime do you think it is "ok" to add Qt's directory in the path variable and use the package compiler?

per tutorial:

"...Don’t know why official website doesn’t provide 64 bit MinGW version of QT. However, you can find 64 bit mingw here. Install it in C:\Qt...MinGw 64bit is already installed with Qt library. You can see it in C:\Qt\qt-5.3.1-x64-mingw482r4-sjlj\m"

Don't put Qt's folder in your PATH, ever, even more as a developer. You might have other applications on your system that uses custom builds of Qt that will be then using the one you put in your PATH so now their functionality is jeopardized.

Use the MinGW version provided with your Qt package. It's been build against it so you don't have to worry about compatibility.

As for why there's no MinGW 64 package ? The CI system building Qt is already creating package for Linux + OS X + Android + iOS + Windows for MSVC2010, 2012, 2013 and MinGW, There's limit to the power and people available to build and test them so the most used version are currently build. It doesn't mean that there won't be package in the future. Also note that each build also runs all tests for every modules.

I'm not sure what you mean by "Qt compiler" as there's no such thing.
Oh boy... lots of ground to cover, but I'll try to briefly explain what is what, why the recommendations are the way they are and when it's safe to not follow them.

Don't mistake Qt, Qt Creator and a compiler. These are three totally separate things.

Qt is just a library compiled with a certain version of a certain compiler (e.g. MinGW, GCC, ICC, Clang or MSVC, each in many different versions). When you use that library in your own code the compiler you use for your code must be the same as the one used to compile Qt, otherwise the generated code won't link or will link and give runtime errors (or will do other undefined things that you really don't want to deal with). If you use something different and get lucky it might be compatible but it's basically a russian roulette if you do.
This is basically why it's suggested to use the compiler bundled with the Qt package - to assure they are compatible (by being exactly the same in that case), but if you have a different compiler and are 100% sure it's compatible then it's perfectly safe to use it.

Now to the PATH matter. There's a global PATH variable. It's the one you set in that darn, too small for 21 century OS, non-resizable box in the Advanced System Settings panel of your computer properties. This is the one you were told not to pollute because every program that runs on your computer uses it and can easily get confused if you put something unexpected there (like a compiler toolchain in this case) or something that it indeed expects but in a different version for example. So just don't pollute it if you don't have to, period.

When you start a process it gets a copy of that PATH. It can freely modify it and it's safe because it's modifying its hermetic copy and no other process in the system sees these changes. The global PATH remains unmodified.
As an example: start cmd.exe and type set PATH=foobar to change the PATH and then echo %PATH% to see its current state. Note that the PATH changes inside cmd but the global system PATH in the Advanced System Settings remains unaffected. As soon as you close the cmd window the changes you made are lost and if you start cmd again it will get a fresh, unmodified copy of the PATH from the system settings.

Now to the matter of how compilers and build tools interact with PATH. Except for maybe learning purposes you rarely compile code by hand, calling g++ or cl.exedirectly. You use an IDE (like Visual Studio, Eclipse or Qt Creator) that calls a build tool like CMake, msbuild, nmake or qmake. This build tool in turn calls the compiler and passes to it all the needed switches.

The build tool doesn't usually call the compiler by its full path e.g. c:\MinGW4.9.1\bin\g++. Instead it assumes the compiler is in a process discoverable place and simply calls g++. One of such process discoverable places are the directories specified in the PATH environment variable. An IDE like Qt Creator runs the build tool as a separate process and modifies its hermetic copy of PATH (and other environment variables) so that it has everything it needs (e.g. the compiler) in its PATH. This operation is perfectly safe and normal, as the changes are only lasting till the build tool finishes its work and are invisible from outside (just like in case of that cmd example above).

Of course IDEs, build tools, compilers, debuggers etc. are separate applications and you can mix and match them as you like (to the extent of their compatibility with one another of course).
To make that easier Qt Creator has a notion of Kits. A Kit is a set of a build tool, compiler, debugger, a copy of Qt libraries and any environment variables they might need. When you build an app from Qt Creator it uses the kit you set up (or was set up automatically by Qt SDK installer) and does all the heavy lifting for you - sets environment vars like PATH, calls all the tools with the right params, attaches the debugger etc.

So, if you were to skip using an IDE and call the compiler directly you could do it many ways, some of which I'll describe:

Open a command line (cmd.exe). Call the compiler by its full path, for example C:\MinGW4.9.1\bin\g++ <all the params>. Of course if you have another compiler (e.g. g++ from MinGW4.8.2 or cl.exe from MSVC10.0) you could call them the same.

Open a command line (cmd.exe). Add the compiler directory to the path set PATH=%PATH%;C:\MinGW4.9.1\bin\; and call g++ <all the params>. This is ok as the changes to PATH are local to your cmd session.

DON'T DO THAT!!!: Modify the global PATH in system setting to include C:\MinGW4.9.1\bin\ in it. Open a command line (cmd.exe, remember that it gets a copy of the system PATH) and call g++ <all the params>. This change of PATH is the global one that you should not do. I hope you see why now - if you have several MinGW versions in it the call to g++ will be ambiguous.

So to conclude - modifying PATH is perfectly ok as long as the changes you make are hermetic. If you need to change it in your command line session or let the IDE do that for you (like with Kits in case of Qt Creator).

This was an excellent eye-opener. I am going to have to stay with the material: it answers the questions and then some. Really, the answer digs deep, and I appreciate the response. I thought it would be at most a paragraph which only shows you the degree of education I needed.

I think any programmer novice - intermediate should read and struggle with this response. It really pulls the sheet off of the problems and shows how these very important things work. I was relying on another with the tutorial; hopefully I can re- read this with more of my own decisions abt this. I messed up somewhere along the way earlier and "something killed my kernel". Long story short I am have reinstalled my system. It should be a cautionary tale. Fortunately I have an SSD drive which made re-installation super fast, and had done disaster planning in advance.

@Technologist I think between you and SGaist I have a lot to digest here. Let me know if u have any further revelations abt the link

C:\Qt\qt-5.3.1-x64-mingw482r4-sjlj\mingw64\bin”

How can I set the path variable to the included compiler with Qt without putting the Qt folder in my path (which as discussed is NOT an option)?
This is the one question that keeps dogging me. I'll continue to read...

"Don't put Qt's folder in your PATH, ever, even more as a developer. You might have other applications on your system that uses custom builds of Qt that will be then using the one you put in your PATH so now their functionality is jeopardized.
Use the MinGW version provided with your Qt package. It's been build against it so you don't have to worry about compatibility."

Can I install Mingw compiler with same version in another directory because can't put qt folder in path? That is still bothering me. I don't want to guess. I can't install it in Qt folder so where does it go? I guess I will put it in c:/

You can have as many independent compilers simultaneously installed as you want and it doesn't matter where they are.
When creating a Kit in the Creator you specify that path and Creator takes care of everything else.

One thing worth noting is that some toolchains don't get along with spaces in paths so try to put them in space free places, for example C:\MinGW4.9.1\ or C:\MinGW_4.9.1\ instead of C:\MinGW 4.9.1\.

But if you already have a MinGW bundled with Qt then what is the point of installing the same version somewhere else? Just use the one from Qt package.

Are you using an IDE or not? What do you want to do? I'm not talking about the details like what's in the PATH or not, just the high level - do you want to build an app using Qt, do you want to compile a Qt-less app, do you want to use an IDE or not etc. ?

In QtCreator I want to want to write a c++ multithreaded app using OpenCV functions to display photos videos with and without Cv analysis in particular object tracking - with Qt as the GUI. I did this several years ago but with WxWidgets, Qt appears much more professional. So I am trying to setup my environment which is the most difficult aspect for me.

In QtCreator I want to want to write a c++ multithreaded app using OpenCV functions to display photos videos with and without Cv analysis in particular object tracking - with Qt as the GUI. I did this several years ago but with WxWidgets, Qt appears much more professional. So I am trying to setup my environment which is the most difficult aspect for me.

I don't know what your installer provides, but these are the basic steps:

Finally, see Adding Kits to tell Qt Creator how to combine your compiler with the Qt binaries.

Done.

If you use the official installers, you don't need to do anything to set up your environment. If you started with a clean machine, simply run the Qt 5.4 installer (MinGW version). The installer installs the Qt libraries, the Qt Creator IDE, and the MinGW compiler. Everything is then automatically set up and ready to go.