0

I have a sln file I usualy compile in visual studio

now I try to compile my project on the command line

I dont use any precompiled headers, so on the command line it feels something is missing because as I do

MSBuild.exe myproject.sln

I get the error

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

like if the config of the project was not read or something

settings picture

trying to force one config/platform , I get this

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.

I have disabled PCH in all platforms, just building without forcing the platform, I get includes errors

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

how do I manage to compile the project properly ? thanks

phil123456
  • 1
  • 1
  • 6
  • 1
    Are precompiled headers switched off for all configurations? – Alan Birtles Mar 01 '19 at 13:20
  • First - check what version of the tools msbuild is picking up. How did you open the command prompt? To build _Win32_ you should use the shortcut called "x86 Native Tools Command Prompt for VS 2017". Secondly, building the solution will probably build _all_ the configurations in that solution. So make sure you turn off PCH's for Configuration: All, Platform: All in the dialog box you linked to. You can do a similar thing in VS by choosing Build -> Batch Build ->Select All -> Build and see which configuration doesn't work. – Mike Vine Mar 01 '19 at 13:20
  • 1
    Also try: "msbuild.exe /p:Configuration=Debug /p:Platform=Win32 myproject.sln" – Mike Vine Mar 01 '19 at 13:26
  • If you still have stdafx.cpp in the project then you also need to turn it off for that specific file. Or completely remove it from the project. Disabling the feature for an SDL project is frankly not a very good idea, unless you like sword-fighting. – Hans Passant Mar 01 '19 at 14:13
  • ok I set the same configs for all platforms, but why is it not accepting /p:Configuration=Debug /p:Platform=Win32 ??? – phil123456 Mar 01 '19 at 17:36
  • `Platform="Any CPU"` is not correct for a native c++ application. It seems like it wants to build a CLR application instead. Do you have some CLR / .NET application inside your project?? – drescherjm Mar 01 '19 at 18:20

1 Answers1

0

Turn off pre compiled headers:

Project Properties -> C++ -> Precompiled Headers set Precompiled Header to "Not Using Precompiled Header".

You may want to read this answer: What is "stdafx.h" used for in Visual Studio?

Gardener
  • 2,591
  • 1
  • 13
  • 22
  • The picture shows this is already set for the Debug / Win32 configuration. Although it may not be set for other configurations. – drescherjm Mar 01 '19 at 13:50
  • I disactivated PCH for all platforms, but why is it not using the default platform and why is it not using my defined inclued folders ??? – phil123456 Mar 01 '19 at 17:29