【问题标题】:MSCV give an error about "unrecognized source file type..." although I didn't specify any argumentsMSCV 给出关于“无法识别的源文件类型...”的错误,尽管我没有指定任何参数
【发布时间】:2021-12-25 08:13:21
【问题描述】:

我遇到了有关 MSVC 的问题。当我尝试运行开发人员命令提示符并键入cl 时,它给了我这个错误:

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'

我不确定发生了什么。我尝试重新安装 Visual Studio 并对其进行修复,但仍然无法正常工作。我尝试做一些研究以找到解决方案,但没有找到。

【问题讨论】:

  • "当我尝试运行开发人员命令提示符并键入 cl" 你为什么这样做?你想要完成什么? cl 需要参数,不带参数运行是没有意义的。
  • 我只是在安装 vs 后测试 msvc 编译器是否工作
  • 我无法在 19.29.30037 上重现此内容。我得到 usage: cl [ option... ] filename... [ /link linkoption... ]
  • @chris 是的,这就是它应该做的
  • 如果我实际运行 cl C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86\cl.exe 而不仅仅是 cl,我会得到相同的输出。你确定这不是实际运行的吗?

标签: c++ visual-studio visual-studio-2019


【解决方案1】:

检查您是否定义了名为CL_CL_ 的用户或系统环境变量。

假设 Windows 10,转到 开始设置系统关于 → 点击高级系统设置链接,然后在系统属性对话框的高级选项卡上,单击环境变量...按钮在那里查看并签入这两个列表。

正如 Microsoft 在 CL environment variables 上所记录的那样,定义此类变量将通过在命令行中附加或附加指定参数来干扰 CL 工具。有时,在调用 MSBuild 之前设置 CL_CL_ 变量对于注入预处理器宏(使用 /D option)以改变编译的某些方面很有用。

通常情况下,环境中不应该有这样的变量。也许您将其中一个变量全局设置为cl.exe 的路径,这是错误的。因此,只需删除变量即可。

【讨论】:

  • 谢谢!删除变量解决了这个问题:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-06-14
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-10
  • 2022-01-01
相关资源
最近更新 更多