QT COMPILER_MACROS not defined on project start

Viewed 2196

I have an annoying issue with QT (version 5.12.1) and I suspect it's because I have a few different versions of Visual Studio also active on my machine. Note that I'm using windows 10 and working with QT creator. The issue is as follows:

When I create a new empty console project, I get the following general message in the IDE:

Running Windows Runtime device detection. No winrtrunner.exe found. C:/Qt/Qt5.12.1/5.12.1/mingw73_64/mkspecs/features/toolchain.prf(76): Variable QMAKE_CXX.COMPILER_MACROS is not defined. Project ERROR: failed to parse default search paths from compiler output Error while parsing file C:\Qt\Test\Proj\Proj.pro. Giving up.

When making a console project, QT will by default, add main.cpp. However I can't add any new source code files (those options are greyed out) and I can't actually access main.cpp.

But if I build the project (via the IDE) it will make a the .o and .exe files, which are meaningless because I've not been able to add anything to the source code. Then, I close QT, open it, and it all works as it should.

I'm using MinGW, however QT can still autodetect the MSVC compilers and debuggers. That shouldn't cause any problems because the default build kit specifies all the MinGW stuff.

Any ideas what the reason could be? All the online searching I've done points towards bugs being logged and fixed for QT5.9, but no clear solution for my problem.

1 Answers

We were having the same problem building on Windows 10, and I think I found a solution. Our project is compiling our Qt project with both Visual Studio 2019 (using the MSVC compiler), and with Qt 5.12.7 (using a MinGW 64bit compiler).

We had a pretty big refactor, so I deleted build directories and *pro.user files. Then I had the same thing happen to our Qt projects. I also created a default project, closed Qt and when I restarted it, I could not parse the *.pro file with the same error you saw. After some investigation, I restored .qmake.stash files that I had deleted (from the Recycle Bin) and the build started working again.

What I pieced out is that Qt depends on qmake running (This bug was supposed to be fixed: https://bugreports.qt.io/browse/QTBUG-60059, but I decided to focus on qmake). After a bunch of trial and error (without a good explanation of why it work), I found a solution.

I got this procedure to work a few times.

  • delete any build artifacts and *pro.user file
  • open project and configure it for MinGW 64bit.
  • get the error
  • to build->run qmake (You can watch the Compile output to see that it runs properly)
  • click on "File"->Close Project
  • click on "Files"->recent projects and pick your project to open again.
  • Now it's fixed!
  • Be safe and do a build.

Also, as long as you don't blow away all the build artifacts while QtCreator is closed, opening the project seems to work find. You can blow away all the artifacts while QtCreator is open, and then rebuild before closing and everthing works ok.

Related