The Moc’ing file will appear when the qt interface file is compiled in Msbuild. The system cannot find the specified path. \

Clicking “Generate solution F7” will cause an error:

Moc’ ing ***.h

The system could not find the specified path. \

C: \ Program Files \ MSBuild \ Microsoft (x86) Cpp \ v4.0 \ Microsoft CppCommon. The targets (171, 5) : error MSB6006 CMD. Exe has quit, code is 3.

Error: MSBuild cannot find Qt’s moc. Exe path, causing precompilation of Q_OBJECT file to fail. Depending on whether the project can compile on local VS, there are two cases:

1. If the Qt class library or Qt Visual Studio Add-in plug-in is not installed properly, you need to install it again.

2, if the compiler fails to pass, the project Qt class library path ($QTDIR) is different from the local VS Qt class library path. Open the project configuration file xxx.vcxproj. User under the project path, you can observe and analyze the QTDIR path. \

Solutions are as follows:

Option 1: Ignore it and simply click “Start executing (no debugging) Ctrl+F5”. The reason is ui_window.h doesn’t recognize it, so just ignore it, just hit Run and ui_window.h will automatically generate. I’ll compile it next time.

2, find VS2015 solution Explorer, right-click the project, pop up the menu, click “convert Project to QMake generated Project”, then the project file xxx.vcxproj.user will change.

Xxx.vcxproj. user The following is an example:


      
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
    <QTDIR>C: \ Qt \ Qt5.9.1\5.9.1 \ msvc2015</QTDIR>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
    <QTDIR>C: \ Qt \ Qt5.9.1\5.9.1 \ msvc2015</QTDIR>
  </PropertyGroup>
</Project>
Copy the code

<QTDIR>C:\Qt\Qt5.9.1\5.9.1\msvc2015</QTDIR> convert project… The tool added it automatically. Automatically add failure, the programmer can be manually added, respectively add Debug | Win32 and Release | under Win32 QTDIR path value, make it the same as the local VS configuration of Qt library path. Recompile.

\

The author uses plan 1 and 2 respectively, successfully solved! If not, we use two!

\