为什么我会为此代码获取多个定义错误?

时间:2014-05-21 20:33:31

标签: c++ opengl linker glfw

我有以下程序,我所拥有的是:

#include <GL/glfw3.h>

int main()
{
     glfwInit();
     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
     glfwTerminate();
}   

我得到glfwWindowHint未定义的引用错误。所以我开始链接glfw3库。

之后我得到了许多函数的多重定义错误,我甚至没有使用:

multiple definition of `glfwSetWindowTitle'|
multiple definition of `glfwSetWindowPos'|
multiple definition of `glfwGetWindowSize'|
multiple definition of `glfwSetWindowSize'|
multiple definition of `glfwIconifyWindow'|
multiple definition of `glfwRestoreWindow'|
multiple definition of `glfwSetWindowSizeCallback'|
multiple definition of `glfwSetWindowCloseCallback'|
multiple definition of `glfwSetWindowRefreshCallback'|
multiple definition of `glfwPollEvents'|
multiple definition of `glfwWaitEvents'|
multiple definition of `glfwInit'|
multiple definition of `glfwTerminate'|
multiple definition of `glfwGetVersion'|
multiple definition of `_glfwStringInExtensionString'|
multiple definition of `glfwSwapBuffers'|
multiple definition of `glfwSwapInterval'|
multiple definition of `glfwExtensionSupported'|
multiple definition of `glfwGetProcAddress'|
multiple definition of `_glfwPlatformSetWindowTitle'|
multiple definition of `_glfwPlatformSetWindowPos'|

我从错误中删除了很多行,但他们都说这些函数首先在libglfw.a中定义,然后多重定义来自libglfw3.a。是的,我在MinGW/lib文件夹中都有这两个文件,但我不明白为什么它们会相互冲突。为什么会发生这种情况?我该如何解决?

我正在联系:

mingw32-g++.exe ... -lglfw -lopengl32 -lglu32 -lgdi32 -lglfw3 

0 个答案:

没有答案