Glew - 与 GLFW 配对时 gl- 函数符号上出现链接错误
Glew - Linking Error on gl- function symbols when paired with GLFW
我正在重新设计一个项目以使用 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++中使用内联方法时出现未定义的符号错误
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 函数指针给我"重新声明为不同类型的符号"错误
- "byte":使用Crypto++和Windows SDK时出现不明确的符号错误
- 函数路径追加上未解决的外部符号错误
- 作为成员的静态类模板实例会导致未解析的外部符号错误
- C++ XCODE ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -
- 共享库中使用"使用命名空间"定义的符号错误
- 在FreesWitch中使用AWS C SDK加载模块时未定义的符号错误
- 在 Mac 上C++编译代码时处理“dyld:惰性符号绑定失败:找不到符号”错误
- C++编译错误LNK2019:未解决的外部符号错误
- VTK / ITK/ QT - 未解决的外部符号错误 (LNK2001)
- QT创建者:简单程序未解决的外部符号和外部符号错误
- C++编译错误:ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v
- 标准::字符串::空的未定义符号错误;Mac OS High Sierra 上的 c++ 标准方法链接错误
- ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 由于使用未签名的INT,因此在Variadic模板C 上未解决的外部符号错误
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- 使用从WINRT网格类派生的抽象类时,Casttobase未解决的外部符号错误
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See