Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Error while parsing example projects
I am a complete beginner in Qt. I installed Qt 5.9.3 with Qt Creator 4.4.1 (via an Qt online installer), but had trouble opening any of the example projects listed on Qt Welcome >> Example page. I searched online and through Qt Forum, but was unable to figure out what I did wrong.
Can someone help me?
The error message shows:
Project ERROR: Cannot run compiler 'g++'. Maybe you forgot to setup the environment?
Error while parsing file C:\Qt\Examples\Qt-5.9.3\widgets\layouts\basiclayouts\basiclayouts.pro. Giving up.
By the way, I use a Windows 10 desktop computer. When installing Qt, I checked the component MinGW 5.9.3 32 bit, the Source component, the Qt Charts, and the Qt Data Visulization components; however, I did not check any other components that were related to MSVC or Android, because I wanted to focus on Windows desktop development first.
Attached below is a .jpg image that shows the error message.
@beginner123 It looks like you did not set up your development environment correctly.
"Project ERROR: Cannot run compiler 'g++'." - this means the the C++ compiler is not installed or not found.
On which platform are you (Windows/Linux/MacOS)?
If on Linux then make sure you have all needed tools installed. On Ubuntu install build-essential package.
Yes, I work on Windows platform.
I think you are right about the environmental settings, but I am having trouble figuring out exactly what I need to do setup the environment properly. Attached below are two .jpg images showing my setup in Qt Creator >> Tools >> Options >> Build & Run >> the Kits tab and the Compilers tab.
In the Kits tab, MinGW is the only Kit that is available. And I think I have configured this Kit properly, as I am able to create simple Qt projects with success. However, my environmental settings somehow do not allow me to parse any of the Qt built-in example projects properly.
In the Compilers tab, I also have MinGW available to me. However, as you can see on the attached images below, Qt also detects the presence of several versions of Microsoft Visual C++ Compilers on my computer. I think it is because that I also have Visual Studio 2015 (the free Community version) installed on the same computer. However, it is my desire to shift from Visual Studio to Qt applications, because I think Qt will work better for my future projects. In the long run, I may simply discard Visual Studio.
Shall I uninstall my Visual Studio? So I don't confuse Qt? OR Are there any parameters in Qt Creator that I need to change, so that Qt can find a correct compiler to use for the Qt built-in example projects?
Thanks a lot in advance for your help!!!
Here is the Kits tab
Here is the Compilers tab
to parse any of the Qt built-in example projects properly.
Is there any chance you had those open before switching to mingw ?
It sounds like you can create a default Widget GUi project and run it?
If you open a example, does it ask for which compiler ?
If no, can you then check in the example folder if .user file might have been created ?
( the .user file might point wrong locations)
You settings looks like mine so I suspect something else is wrong.
Also as a note. You can also use Creator and the visual studio compiler.
It often works better with external libs and i find it slighter faster than mingw.
Nothing wrong with mingw though. Just saying you can also mix it by using the
compiler from Visual Studio + QtCreator and not the visual studio IDE.
@beginner123 Your kit settings looks good so far.
What I don't understand is the "Windows Runtime device detection" message in your first screenshot.
I can't remember having ever seen this. And I guess this is part of your problem.
Yes, I can create a new Widget GUI project and run it with no problem. However, for some unknown reason, I cannot open any of the Qt built-in example projects.
I tried to uninstall and re-install Qt, but it did not solve the problem. I even included all components under Qt 5.9.3 and all components related with MSVC, but it still did not solve the problem, neither.
I think you are right about the .user file. When I was trying to open a Qt built-in example project (for example, Basic Layouts Example), it did not ask me for a compiler at all. It simple showed me an error message, as shown in a snapshot image above.
Following your advice, I looked into the files that were stored in this example project. I found that there was no .user file at all. All I have is the basiclayouts.pro, main.cpp, dialog.cpp, and dialog.h. I think this may be a good starting point to solve this problem.
Attached below is a snapshot of the file system of this example project, and the content of its basiclayouts.pro file.
Inside this basiclayouts.pro file, this was an item that caught my eyes. It was the parameter $$[QT_INSTALL_EXAMPLES]. Is it possible that this parameter is somehow pointing to a wrong location? If so, where shall I go to see the actual value of this parameter?
Thanks a lot in advance for your time and willingness to help me out!!!
It seems it tried to compile for arm ??
When you open project and it ask for compiler, try to select only the mingw
The $[QT_INSTALL_EXAMPLES] as used here is for doing
and as far as i know should not have influence on the g++ not found error.
@beginner123 As @mrjj says (and what I already told yesterday) it seems you have selected something related to WinRT (on ARM). Can you show us the compiler setup screen when you open the project the first time? (make sure to delete all .user and Makefile and other build results in the project).
My apologies for the error related to "arm". It was because that I uninstalled and re-installed Qt (with all components added, including "arm"). I thought if I included all those components, it might solve the problem. But it did not.
For clarity and simplicity, I uninstalled Qt and re-installed Qt again with just MinGW and Qt Creator included. That is, no "arm" nor "MSVC" components.
Here is a snapshot when I opened the example project the first time.
If anyone can advise me on what I need to do to configure this example project, I would greatly appreciate it.
Thanks again for your time and willingness to help me out!!!
So even after only having mingw and the mingw Qt installed, it still says it cannot find
Can you manually check your listed path and verify that the .exe is actually in the path listed?
@beginner123 I'm sorry, but this is a really weird problem. The only thing I can still imagine is that something (antivirus) blocks the access to the compiler.
If this is not the case, then you can file a bug at bugreports.qt.io
I've always used the MinGW installer and never saw problems like yours.
Edit: got one more idea: do you have write access rights in the examples + the parent folder?
Yeah Im also puzzled as a default project works but
the samples wont.
JonB last edited by JonB
Since the problem is weird & intractable, would the experts here suggest asking the OP if he fancied uninstalling & reinstalling things Qt & Compiler, depending on how much effort that is?
EDIT: Sorry, missed that, already tried.
He actually already have tried that and got same result.
There seems to be nothing wrong with the kits and a default
project works whereas any sample loaded complains.
I got it!!!
I think I have found what I did wrong.
Here is a snapshot of what I should have done.
I should have added MinGW in this example project (circled in red).
After I added the MinGW kit to this example project, it allowed me to build and run this project.
Here is a snapshot of the results.
The example Widget GUI popped up properly and functioned as it should be. HOORAY!!!
The only thing left is the "No winrtrunner.exe found." I will try to figure that out later.
I am SO HAPPY!!!
Thank you ALL SO MUCH!!!!
The power of an open forum at Qt here is another factor that has swayed me from Visual Studio to Qt.
Thanks a lot, guys!!!
Good work not given up.
You can just ignore "No winrtrunner.exe found."
I also get that.
@beginner123 Glad you figured it out. Have fun! :)