gpt4 book ai didi

c++ - Glew - 与 GLFW 配对时 gl- 函数符号的链接错误

转载 作者:行者123 更新时间:2023-11-28 04:49:41 36 4
gpt4 key购买 nike

我正在重新设计一个项目以使用 GLFW 而不是 FreeGLUT,我想我一定设法删除了我的链接器设置中的某些内容。我正在使用 GLEW,虽然我最初认为我已经以某种方式解开了它,但它并没有给我所有与 GLEW 相关的函数调用的错误,只有几个。我已经检查了我使用 git 对属性文件所做的更改,唯一的更改是将 freeglut.lib 替换为 glfwdll.lib

错误信息:

1>main.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glDepthFunc@4 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _main
1>Renderer.obj : error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall Renderer::Render(unsigned int const &,unsigned int const &,struct RenderVariables const &,unsigned int const &,unsigned int const &)" (?Render@Renderer@@QAEXABI0ABURenderVariables@@00@Z)
1>Sprite.obj : error LNK2001: unresolved external symbol __imp__glBindTexture@8
1>Renderer.obj : error LNK2019: unresolved external symbol __imp__glDrawArrays@12 referenced in function "public: void __thiscall Renderer::Render(unsigned int const &,unsigned int const &,struct RenderVariables const &,unsigned int const &,unsigned int const &)" (?Render@Renderer@@QAEXABI0ABURenderVariables@@00@Z)
1>Sprite.obj : error LNK2019: unresolved external symbol __imp__glGenTextures@8 referenced in function "public: bool __thiscall Sprite::loadSprite(char *)" (?loadSprite@Sprite@@QAE_NPAD@Z)
1>Sprite.obj : error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function "public: bool __thiscall Sprite::loadSprite(char *)" (?loadSprite@Sprite@@QAE_NPAD@Z)
1>Sprite.obj : error LNK2019: unresolved external symbol __imp__glTexImage2D@36 referenced in function "public: bool __thiscall Sprite::loadSprite(char *)" (?loadSprite@Sprite@@QAE_NPAD@Z)
1>Sprite.obj : error LNK2019: unresolved external symbol __imp__glTexParameterf@12 referenced in function "public: bool __thiscall Sprite::loadSprite(char *)" (?loadSprite@Sprite@@QAE_NPAD@Z)
1>Sprite.obj : error LNK2019: unresolved external symbol __imp__glTexParameteri@12 referenced in function "public: bool __thiscall Sprite::loadSprite(char *)" (?loadSprite@Sprite@@QAE_NPAD@Z)

然后,我的 main() 函数,这是唯一在转换期间最终发生变化的函数:

void main(int argc, char** argv) 
{
if (!glfwInit())
{
exit(-1);
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);

GLFWwindow* window = glfwCreateWindow(width, height, "Space Invaders", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
endGame(-1);
}
glfwMakeContextCurrent(window);
glViewport(0, 0, width, height);

// A call to glewInit() must be done after GLFW is initialized!
GLenum res = glewInit();
// Check for any errors
if (res != GLEW_OK) {
fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
endGame(1);
}

gameState = new GameState();

init();

while (!glfwWindowShouldClose(window))
{
pollInput(window);
display();
glfwSwapBuffers(window);
glfwPollEvents();
}
endGame(0);
}

我注意到每个抛出错误的函数都有 gl- 前缀而不是 glew-,既然我没有使用 freeglut,我还需要添加另一个库吗?我目前只链接 glfw 和 glew。

最佳答案

好吧,我不确定以前没有它我是如何管理的,但我还需要链接 OpenGL32.lib

关于c++ - Glew - 与 GLFW 配对时 gl- 函数符号的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48492308/

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