首页 > 解决方案 > 致命错误:GLFW/glfw3.h:没有这样的文件或目录

问题描述

当我尝试导入 GLFW 时,我在 VSCode 中收到错误消息“致命错误:GLFW/glfw3.h:没有这样的文件或目录”。我阅读了一些有关此错误的文章,但不明白如何解决此问题。谢谢您的帮助!

项目结构:

src/
   main.c
lib/
   GLFW/
       include/
              GLFW/
                  glfw3.h
       glfw3.lib

这是我的 main.c 代码:

#include <stdio.h>
#include <GLFW/glfw3.h> // fatal error: GLFW/glfw3.h: No such file or directory

int main() {
    printf("Hello, World!");

    return 0;
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}\\src\\**",
                "${workspaceFolder}\\lib\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}

任务.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\MinGW\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\\MinGW\\bin\\gcc.exe"
        }
    ]
}

标签: cvisual-studio-code

解决方案


推荐阅读