c++visual-studiolinker-errors

MS Visual c++ "The number of source files and corresponding outputs must match"


I'm trying to compile my code on c++ in msVisual2019 but I get an error at every try:

Severity    Code    Description Project File    Line    Suppression State
Error   MSB6001 Invalid command line switch for "CL.exe". System.ArgumentException: The number of source files and corresponding outputs must match.
   at Microsoft.Build.Shared.ErrorUtilities.ThrowArgument(Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Utilities.CanonicalTrackedOutputFiles.RemoveDependenciesFromEntryIfMissing(ITaskItem[] source, ITaskItem[] correspondingOutputs)
   at Microsoft.Build.CPPTasks.CL.PostExecuteTool(Int32 exitCode)
   at Microsoft.Build.CPPTasks.TrackedVCToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
   at Microsoft.Build.Utilities.ToolTask.Execute()  HelloWorld  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 687

This first happened after I created (on accident) a header file inside "Source Files" (img attached), compiled it, then realized my mistake and placed it back in "Header Files". Now every time I build it, even after every change I make... I can't get this error to go away and haven't found a solution to a similar problem yet. Any help would be greatly apreciated, thanks.

mistake, build after

correction, build after

errors displayed


Solution

  • Preprocess to a File doesn't seem like a good idea according to its description: This option suppresses compilation... I'm glad you set it to No. – rturrado Jul 10 at 21:04 Thanks @rturrado :D