命令。使用 VSCode 编译 C 文件时出现 exe 错误 + win环境下的Clang

发布于 2025-01-13 18:56:28 字数 1420 浏览 2 评论 0原文

我编写了一个名为 helloengine_win.c 的新 .c 文件,并使用快捷键 shift + ctrl + b 来编译它。 tasks.json 是:

{
"version": "2.0.0",
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: clang.exe",
        "command": "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang.exe",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "-L",
            "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x64\\User32.Lib",
            "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x64\\Gdi32.Lib"
        ],
        "options": {
            "cwd": "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\**"
            
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "\"D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang.exe\""
    }
]

}

该文件使用 GetStockObject() 所以我需要 lib User32.LibGdi32.lib< /code>

但是当我编译文件时我得到: spawn C:\Windows\system32\cmd.exe ENOENT 生成已完成,但发生错误

我已经确认所有库文件都存在,并且文档中没有报告任何错误。我不知道是什么错误的。

I write a new .c file named helloengine_win.c and use shortcuts shift + ctrl + b to complier it.
The tasks.json is :

{
"version": "2.0.0",
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: clang.exe",
        "command": "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang.exe",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "-L",
            "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x64\\User32.Lib",
            "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x64\\Gdi32.Lib"
        ],
        "options": {
            "cwd": "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\**"
            
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "\"D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang.exe\""
    }
]

}

The file uses GetStockObject() so I need the lib User32.Lib and Gdi32.lib

But when I complier the file I get :
spawn C:\Windows\system32\cmd.exe ENOENT generation is complete, but an error occurred

I have confirmed that all library files exist and no errors are reported in the documentation.I don't konw what's wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文