glfw3.dll 运行代码时未找到系统错误

问题描述 投票:0回答:1

我已经在 Visual Studio Code(代码编辑器,而不是 IDE)中设置了 GLFW。当我运行代码时,它给我一个系统错误:- glfw3.dll not found.

这是我从 GLFW 文档中复制的代码:

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

这是我的tasks.json 文件:-

    {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                "/I${workspaceFolder}\\glfw\\include",
                "/Fe:",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${workspaceFolder}\\*.cpp",

                "opengl32.lib",
                "${workspaceFolder}\\glfw\\lib-vc2019\\glfw3dll.lib"

            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: cl.exe"
        }
    ]
}

这是截图:

c++ opengl visual-studio-code c++17 glfw
1个回答
0
投票

您需要将库链接到您的链接器。转到项目设置、链接器,然后添加其他库的路径。路径可以是vcpkg的lib文件夹。

© www.soinside.com 2019 - 2024. All rights reserved.