将GLAD包含到项目中,编译时获取“未解析的外部符号gladLoadGLLoader”

时间:2018-05-14 18:02:12

标签: c++ opengl unresolved-external

我正在使用OpenGL并尝试将GLAD包含到我的项目中,但是我不确定在哪里链接glad.c

我收到了错误

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol gladLoadGLLoader referenced in function "public: __cdecl zelmEngineCore::zelmEngineCore(void)" (??0zelmEngineCore@@QEAA@XZ) OpenGLGLFWTestApp 

我的依赖项文件就是这样

#pragma once

#ifdef _WIN64
    #include <Windows.h>
#endif

#include <string>
#include <iostream>
#include <vector>

#include <glad\glad.h>
#include <GLFW\glfw3.h>

我在打电话 -

gladLoadGLLoader((GLADloadproc)glfwGetProcAddress;

来自zelmEngineCore的构造函数。

这里是构造函数

#include "zelmDependencies.h"
#include "zelmEngineWindow.h"

zelmEngineCore::zelmEngineCore()
{
    if (!glfwInit())
    {
        std::cout << "Error: Couldn't initalise glfw!";
    }

    //Set error callback function
    //glfwSetErrorCallback(zelmEngineCore::glfwErrorCallback);

    //Before creation of the window, you can set the minimum OpenGL
    //version, but we're not using openGL, so it not needed
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

    gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); //Causing the unresolved exteral symbol
}

zelmEngineCore::~zelmEngineCore()
{
    glfwTerminate();
}

我的zelmEngineCore类如下 -

#pragma once

#include "zelmDependencies.h"
#include "zelmEngineWindow.h"

class zelmEngineCore
{
private:

protected:

public:
    zelmEngineCore();
    ~zelmEngineCore();
};

这里是main.cpp

#include "zelmEngine\zelmEngineCore.h"

int main()
{
    zelmEngineCore engine;

    return 0;
}

这个我的C / C ++ / General附加目录包括,我的印象我没有正确包含glad.c文件。我尝试将它包含在链接器中,但我也得到印象链接器用于.lib(s)包括。 C/C++ / General

0 个答案:

没有答案