链接器命令失败,退出代码为 1(使用 -v 查看调用)VisualStudio

Linker command failed with exit code 1 (use -v to see invocation) VisualStudio

我在尝试构建我的应用程序时遇到了非常烦人的错误。

这是完整的错误堆栈

Severity    Code    Description Project File    Line
Error       linker command failed with exit code 1 (use -v to see invocation)   PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\clang.exe  1
Error       undefined reference to 'glGetAttribLocation'    PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   70
Error       undefined reference to 'glCreateProgram'    PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   87
Error       undefined reference to 'glAttachShader' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   91
Error       undefined reference to 'glAttachShader' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   92
Error       undefined reference to 'glLinkProgram'  PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   93
Error       undefined reference to 'glGetProgramiv' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   96
Error       undefined reference to 'glDeleteProgram'    PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   100
Error       undefined reference to 'glCreateShader' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   111
Error       undefined reference to 'glShaderSource' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   115
Error       undefined reference to 'glCompileShader'    PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   116
Error       undefined reference to 'glGetShaderiv'  PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   119
Error       undefined reference to 'glGetShaderiv'  PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   124
Error       undefined reference to 'glDeleteShader' PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   128
Error       undefined reference to 'glUseProgram'   PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   172
Error       undefined reference to 'glVertexAttribPointer'  PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   174
Error       undefined reference to 'glEnableVertexAttribArray'  PewPew.NativeActivity   c:\workspace\PewPew\PewPew\PewPew.NativeActivity\Renderer.cpp   175

嗯,好像跟OpenGL的调用有关,不过具体是怎么搞不懂。

我已经包含了

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <GLES/gl.h>

但还是没有运气。

关于我做错了什么有什么建议吗?

好的,没关系,伙计们,我只是自己想出来的。

出现此问题是因为我尝试使用 GLES 2.0 函数,而不是 GLES 1.0(创建新的 NativeActivity 应用程序时默认设置)。所以,基本上您需要做的就是右键单击您的项目并转到 Properties -> Linker -> Input -> Library Dependencies 并将 GLESv1_CM 更改为 GLESv2.