I'm having a problem about MSVC. When I try run Developer command prompt and type cl
, it give me this error:
Microsoft (R) C/C Optimizing Compiler Version 19.29.30137 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9024 : unrecognized source file type 'C:\Program', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'Files', object file assumed
cl : Command line warning D9024 : unrecognized source file type '(x86)\Microsoft', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'Visual', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86\cl.exe', object file assumed
Microsoft (R) Incremental Linker Version 14.29.30137.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:Program.exe
C:\Program
Files
(x86)\Microsoft
Visual
Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86\cl.exe
LINK : fatal error LNK1104: cannot open file 'Program.exe'
I'm not sure what happening. I try reinstalling Visual Studio and repairing it yet still not working. I try to do some research to find the solutions, none found.
CodePudding user response:
Check if you have a user or system environment variable called either CL
or _CL_
defined.
Assuming Windows 10, go to Start → Settings → System → About → click on the Advanced system settings link, then in the System Properties dialog, on the Advanced tab, click the Environment Variables… button to see and check in both lists there.
As documented by Microsoft on CL environment variables, defining such variables will interfere with the CL tool by prepending or appending the specified arguments to the command line. Sometimes, setting a CL
or _CL_
variable before invoking MSBuild is useful for injecting preprocessor macros (using the /D
option) to alter some aspect of the compilation, for example.
Normally, there should be no such variables in the environment. Perhaps you have one of those variables globally set to the path of cl.exe
, this is wrong. So, just delete the variable(s).