Unsolved qmake cannot run g++: $$system() not working under Windows 7
-
I've been struggling with this issue for two days now.
I am trying to compile a very simple project with QTCreator using the MinGW 5.3.0 kit under Windows 7, but I get the following error from qmake:Project ERROR: Cannot run compiler 'g++'. Output: =================== =================== Maybe you forgot to setup the environment?
I double-checked that the compiler was in place and functional. Investigating the issue further, I found out that the error occurs when parsing the
mingw53_32/mkspecs/features/toolchain.prf
file on this line:output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ - 2>&1 $$cmd_suffix", lines, ec)
which expands to
output = $$system("set LC_ALL=C& g++ -fno-keep-inline-dllexport -E -v -xc++ - 2>&1 <NUL >NUL", lines, ec)
Turns out, the
$$system()
function does not output anything at all no matter the arguments. For example, I tried substituting it withoutput = $$system("echo test")
and still the contents of
output
were empty. I know this because I tried launchingqmake
manually with the-d
flag. I also played around with thetoolchain.prf
file a little, adding some debug output. Here i attached the log file I got from this command:D:\Qt\5.11.3\mingw53_32\bin>D:\Qt\5.11.3\mingw53_32\bin\qmake.exe D:\QTProjects\untitled9\untitled9.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" -d > qmake-test.txt 2>&1
This is happening with Qt 5.11.3., but it is also relevant to 5.12.2 and 5.13.0. In fact, I downgraded from those in hopes of curing this problem. I'm glad to share any additional info that is required to resolve this issue. Please help, it's driving me crazy.
-
Hi and welcome to devnet,
Might be a silly question but did you install MinGW through the Qt installer also ?
-
@SGaist yes, I did. I also tried using a manually added compiler from the MSYS2 package installed separately, with the same result
-
Do you have any yellow/red icon in your kit page in Qt Creator's preferences ?
-
@SGaist no, the kit appears to have been configured properly. The bundled gcc, g++ and gdb were nicely detected out-of-the-box.
-
Did you try to close Qt Creator, nuke the build folder, the .pro.user file and then reconfigure your project ?
-
@SGaist no, but I did create new helloworld projects several times. Also, as far as I can tell, the problem occurs before any project-specific files and settings get involved
-
Do you still currently have several versions of MinGW ?
If so, can you remove the others ?
-
@SGaist I will try that as soon as I get to my workstation. However what I did try was nuking the QTCreator's folder in
AppData/Roaming
, which caused all settings to reset, which included forgetting those manually added MinGW compilers. The bundled ones were detected again, and the kits were shown as if configured correctly -
@SGaist I removed all versions of MinGW except the one that came with Qt. My kit page in Qt Creator's preferences now has only one auto-detected kit "Desktop Qt 5.11.3 MinGW 32bit" which shows no errors or warnings. It's configured to use the MinGW binaries from
Qt\Tools\mingw530_32\bin\
. Upon creating a new Qt Widgets project the issue persists. There's also this message before I even try to build the project:Project ERROR: failed to parse default search paths from compiler output
and any Qt-related symbols and includes in the code editor are highlighted as unknown. It was there all along, I just didn't mention it. I believe it is caused by the same issue I described in the original post.
I should also mention that I did not compile Qt manually or make any modifications to it. I used the default online installer to install 5.12.2 and 5.13.0, and I used an offline installer to install 5.11.3.
-
I used the ProcessMonitor application from the Windows SysInternals Suite to try to determine where things go wrong. It looks like
qmake.exe
doesn't even try to rung++
. If it did, — unsuccessfully — the log would contain a line which would look like
qmake.exe — QueryOpen — D:\some\path\which\doesnt\exist\g++.exe — NAME NOT FOUND
This, as you can see from the screenshot, is not the case. -
This is how my kits and compilers pages in preferences are looking currently. Sorry for the Russian captions.
Kits:
Compilers:
-
All looks pretty good...
I suppose you can also successfully start g++ from the command line if you use the full path to the compiler ?
-
@SGaist yes, indeed I can. I also added
D:\Qt\Tools\mingw530_32\bin
, the path containing it, to thePATH
environment variable, just for good measure. -
I am currently running out of ideas...
As a last resort, did you try a full Qt uninstallation/computer reboot/Qt installation ?
-
@SGaist this happens to me and is very frustrating. The only solution i have is to create a new w10 account and install a new Qt there. I have no issues on other 2 w10 machines.