gpt4 book ai didi

c++ - 'cl' 未被识别为内部或外部命令,

转载 作者:IT老高 更新时间:2023-10-28 13:58:59 29 4
gpt4 key购买 nike

我正在尝试使用 Qt Creator 在 Qt 中编译一个 hello world 程序。

我得到 'cl' 未被识别为内部或外部命令。

我使用的是 Windows 7 以及安装在其中的 Vs 2008 和 2010。当我使用 Mingw 时,它编译得很好,但如果使用 vs 2008 则会出现此错误。

设置 Env Path =..;..;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin 后也显示相同的错误。

最佳答案

发生该错误是因为 cl 不在您的路径中。你需要在那里添加它。推荐的方法是启动开发者命令提示符

引用文章 Use the Microsoft C++ toolset from the command line :

  1. On the desktop, open the Windows Start menu. In Windows 11, choose the All apps button to open the list of installed apps. In Windows 10,the list is open to the left. Scroll down the list to find and openthe folder (not the app) for your version of Visual Studio, forexample, Visual Studio 2022.

  2. In the folder, choose the Developer Command Prompt for your version of Visual Studio. This shortcut starts a developer commandprompt window that uses the default build architecture of 32-bit,x86-native tools to build 32-bit, x86-native code. If you prefer anon-default build architecture, choose one of the native or crosstools command prompts to specify the host and target architecture.

For an even faster way to open a developer command prompt, enterdeveloper command prompt in the desktop search box. Then choose theresult you want.

正如文章所述,有几种不同的快捷方式可用于设置不同的工具集 - 您需要选择合适的。

如果您已经打开了一个普通的命令提示符窗口,您可以运行带有适当参数的批处理文件 vcvarsall.bat 来设置环境变量。引用同一篇文章:

  1. At the command prompt, use the CD command to change to the Visual Studio installation directory. Then, use CD again to change to thesubdirectory that contains the configuration-specific command files.For Visual Studio 2019 and Visual Studio 2017, use theVC\Auxiliary\Build subdirectory. For Visual Studio 2015, use the VCsubdirectory.

  2. Enter the command for your preferred developer environment. For example, to build ARM code for UWP on a 64-bit platform, using thelatest Windows SDK and Visual Studio compiler toolset, use thiscommand line:

    vcvarsall.bat amd64_arm uwp

从文章中,第一个参数的可能值如下:

  • x86(x86 32 位原生)
  • x86_amd64x86_x64(x64 on x86 cross)
  • x86_arm(x86 交叉上的 ARM)
  • x86_arm64(ARM64 on x86 cross)
  • amd64x64(x64 64 位原生)
  • amd64_x86x64_x86(x86 on x64 cross)
  • amd64_armx64_arm(ARM on x64 cross)
  • amd64_arm64x64_arm64(ARM64 on x64 cross)

关于c++ - 'cl' 未被识别为内部或外部命令,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8800361/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com