【问题标题】:C++ - SDL2 and OpenGL - Visual Studio error LNK2019: unresolved external symbol [duplicate]C++ - SDL2 和 OpenGL - Visual Studio 错误 LNK2019:无法解析的外部符号 [重复]
【发布时间】:2014-08-26 03:20:14
【问题描述】:

我正在学习如何使用 SDL2,并且正在学习 LazyFoo 的教程。

我已经下载了第 50 课的源代码,它教了如何将 OpenGL 与 SDL2(link to tutorial) 一起使用并尝试执行它,但我遇到了很多错误,我不知道该怎么办!

这些是错误:

Error   11  error LNK1120: 9 unresolved externals   c:\users\felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\Debug\SDL2 Template1.exe SDL2 Template1
Error   2   error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)  c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   3   error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)  c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   4   error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)   c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   5   error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)    c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   6   error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)  c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   7   error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)  c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   8   error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)    c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   9   error LNK2019: unresolved external symbol __imp__glVertex2f@8 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)   c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Error   10  error LNK2019: unresolved external symbol _gluErrorString@4 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)    c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\50_SDL_and_opengl_2.obj   SDL2 Template1
Warning 1   warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library    c:\Users\Felipe\Desktop\Arquivos\Drawing - Modeling - Coding\Visual Studio 2013\SDL2 Template1\SDL2 Template1\MSVCRTD.lib(cinitexe.obj) SDL2 Template1

我从未使用过 OpenGL,所以我不知道发生了什么。

这是什么意思?我该如何解决这个问题?

【问题讨论】:

    标签: c++ visual-studio opengl sdl sdl-2


    【解决方案1】:

    您似乎缺少一个库文件,很可能是 OpenGL32.lib。如果您有该库可用,请将其添加到您的项目中。

    查看此页面,靠近底部:http://msdn.microsoft.com/en-us/library/windows/desktop/dd318361(v=vs.85).aspx

    【讨论】:

    • 我该怎么做?和我对 SDL2 库做的一样吗?我在哪里可以找到 OpenGL32.li?
    • @Deive_Ex ' 我在哪里可以找到 OpenGL32.li?' 你之前可能在哪里安装过它?
    • @πάνταῥεῖ 事情就是这样:我从未安装过 OpenGL。它不应该默认在我的机器中吗?
    • @πάνταῥεῖ 哦,我搜索了一下,在我的 ProgramsFiles(x86) 中找到了一个名为“Windows Kits”的文件夹(奇怪的是,即使我使用的是两个文件夹,分别为 8.0 和 8.1 Windows 7),在那里我找到了另一个名为“gl”的文件夹,它有 lib 和 include 文件夹以及 OpenGL32.lib 文件。我以与添加 SDL2 相同的方式添加它们,现在我没有收到任何其他错误,除了错误 10(gluErrorString 事物)和警告。
    • 我遇到了同样的问题...在任何地方都找不到 OpenGL32.lib 文件。感谢您发布它在那个 Windows Kits 文件夹中,否则我会迷路的!
    猜你喜欢
    • 2013-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-10
    • 2014-10-09
    • 1970-01-01
    相关资源
    最近更新 更多