PDA

View Full Version : Qt5 project in VS2010 cannot be built: Error MSB6006



Brokenmind
18th September 2013, 23:01
Good evening,

first posting... let's see how much I can do wrong!

I've been developing a QT OpenGL application in C++, VS2010 for some time now. The below error occurred once before; back then, I managed to fix it with a backup of the project. Now, it seems to be permanent!

When building the project in Visual Studio, the following error occurs:

error MSB6006: "cmd.exe" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppComm on.targets, line 151, col 6
This error just came up out of the blue when I did absolutely not change anything (just building before starting to code). Google advises to change various settings, delete, reinstall... all done, solved nothing.
The problem also occurs with newly created QT5 projects without any other content. Turning the VS log level to "diagnose" shows the following:


1> "E:\Qt\Qt5.0.2\5.0.2\msvc2010_opengl\bin\rcc.exe" -name "testproject" -no-compress "c:\TestProject\TestProject\testproject.qrc" -o .\GeneratedFiles\qrc_testproject.cpp (task ID: 16)
1> Moc'ing testproject.h... (task ID: 16)
1> moc: Cannot create .\GeneratedFiles\Debug\moc_testproject.cpp (task ID: 16)
1> Uic'ing testproject.ui... (task ID: 16)
1> Could not create output file (task ID: 16)
1> Rcc'ing testproject.qrc... (task ID: 16)
1>RCC : warning : No resources in 'c:\TestProject\TestProject\testproject.qrc'.
1> (task ID: 16)
1> Unable to open .\GeneratedFiles\qrc_testproject.cpp for writing: The system can not find the specified path. (task ID: 16)
1> (task ID: 16)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppComm on.targets(151,5): error MSB6006: "cmd.exe" exited with code 1.
Before that, everything seems to run just fine.

So, the problem might be that the MOC files could not be created. The solution here (http://stackoverflow.com/questions/11941885/moc-ed-files-being-exluded-from-build-in-visual-studio-2010) did not work.

Any help on this problem would be much appreciated! Please tell me if there's any information I could add.
Some facts: Visual Studio 2010, Qt5.0.2, QT VS Addin 1.2.1, OS: Windows 7
Attempted solutions: Reinstalled QT / QT Addin / VS2010 / tried VS2012. Problem occurs only in QT5 projects (not in e.g. C++ console applications).

Thanks for any help in advance!

Regards,
Brokenmind

ChrisW67
19th September 2013, 00:41
It looks like you have a relative path in MOC_DIR and the current working directory is not where you think it is, i.e. it is trying to write a file in a prohibited location like the Visual Studio program directory.

Brokenmind
19th September 2013, 09:51
You're right, changing the ".\GeneratedFiles\..." to an absolute path solved the above issue, but this cannot be an acceptable solution to the problem, right?
Furthermore, the build process seems to work now, but the program crashes when attempting to run it:

Debug Error!

Program: C:\TestProject\Win32\Debug\TestProject.exe
Module: 5.0.2
File: kernel\qguiapplication.cpp
Line: 782

Failed to load platform plugin "windows". Available platforms are:

(Press Retry to debug the application)
Retrying gets me to "free.c" in mvscr100d.dll, where apparently some heap couldn't be freed.

I could not locate the file qguiapplication.cpp on the whole file system... Now I can either try to figure out why the relative path in MOC_DIR is not working and why changing it to an absolute path makes the remaining program unusable, or I can try to fix the heap exception thrown in a file which does not exist. But I have no clue about both. Seriously, what's going on here?

ChrisW67
20th September 2013, 07:45
The error is telling you that the runtime environment of your process cannot find the platform plugin. The platform plugin and source file is part of Qt5.
If you are running the program in your IDE then you have a broken installation.
If you are running the program in a deployed environment then you have failed to deploy the necessary plugin(s).


The relative MOC_DIR path is not inherently wrong. That path is relative to the current working directory in which qmake is run. If your IDE is running qmake with the current working directory set to somewhere that cannot be written then there is a misconfiguration of either the IDE or the project settings (e.g. a broken shadow build path).