繁体   English   中英

Visual Studio 2017-通过命令行和MSBuild进行构建-缺少stdafx.h

[英]Visual studio 2017 - building via command line & MSBuild - missing stdafx.h

我有一个通常在Visual Studio中编译的sln文件

现在我尝试在命令行上编译我的项目

我不使用任何预编译的头文件 ,因此在命令行上感觉缺少了某些内容,因为像我一样

MSBuild.exe myproject.sln

我得到错误

unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"'

如项目的配置未读取或类似

设置图片

试图强制一个配置/平台,我得到这个

c:\myproject>"P:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild".exe game2D_sdl.sln /p:Configuration=Debug /p:Platform=Win32
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 1/03/2019 18:08:47.
Project "c:\myproject\game2D_sdl.sln" on node 1 (default targets).
c:\myproject\game2D_sdl.sln.metaproj : error MSB4126: The specified solution configuration "Debug|Win32" is invalid. Please specify a valid solution configuration using the Configuration an
d Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [c:\myproject\g
ame2D_sdl.sln]
Done Building Project "c:\myproject\game2D_sdl.sln" (default targets) -- FAILED.

我已在所有平台上禁用了PCH,只是在不强制平台的情况下进行构建,但出现包含错误

c:\myproject>"P:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild".exe game2D_sdl.sln
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 1/03/2019 18:13:52.
Project "c:\myproject\game2D_sdl.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x64".
Project "c:\myproject\game2D_sdl.sln" (1) is building "c:\myproject\game2D_sdl\game2D_sdl.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
  Touching "x64\Debug\game2D_sdl.tlog\unsuccessfulbuild".
ClCompile:
  P:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\CL.exe /c /ZI /nologo /W3 /WX- /diagnostics:classic /sdl /Od /D _DEBUG /D _CONSOLE /D _UNICOD
  E /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Debug\\" /Fd"x64\Debug\vc141.pdb" /Gd /TP /FC /errorReport:queue animations.cpp audio.cpp
   box.cpp .... animations.cpp .....
c:\myproject\game2d_sdl\game2d_sdl.h(13): fatal error C1083: Cannot open include file: 'nlohmann/json.hpp': No such file or directory [c:\myproject\game2D_sdl\game2D_sdl.vcxproj]
  audio.cpp

我如何正确地编译项目? 谢谢

关闭预编译的头文件:

项目属性-> C ++->预编译头将“预编译头”设置为“不使用预编译头”。

您可能需要阅读以下答案: 在Visual Studio中,“ stdafx.h”的作用是什么?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM