我正在尝试在Code :: Blocks中设置要用MinGW编译的GLFW。尝试构建示例代码以从GLFW的站点创建窗口后,我收到:
未定义对InitializeCriticalSection @ 4的引用
这是我第一次尝试使用OpenGL和GLFW进行项目。我已经下载了GLFW,并按照说明进行操作;将glfw3.h,libglfw3.a,libglfw3dll.a放入正确的lib并包含文件夹。我将glfw3.dll放入了System32文件夹中(并尝试将其放置在同一lib文件夹中)。
我已更改链接器设置,以包括针对所有配置的以下库(按给定顺序):
libkernal32.a
libwsock32.a
libgdi32.a
libopengl32.a
libglfw3dll.a
libglfw3.a
我包括了gdi32和wsock32,因为其他论坛提到它们是常见的缺少库。我在MSDN上发现InitializeCriticalSection与kernal32相关。
//It's literally copy and pasted from GLFW Documentation, only added the define and include:
#define GFLW3_DLL
#include <GL/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
我希望没有警告或错误,这是我得到的:
错误提示:
C:\ Users \ mcore \ Program Files \ CodeBlocks \ MinGW \ lib / libmingw32.a(tlsthrd.o):tlsthrd.c :(。text + 0x208):对InitializeCriticalSection@4
的未定义引用
错误:ld返回1个退出状态
警告:
警告:通过链接到_VirtualQuery解决_VirtualQuery @ 12
警告:通过链接到_VirtualProtect解决_VirtualProtect @ 16
警告:通过链接到_EnterCriticalSection来解决_EnterCriticalSection @ 4
警告:通过链接到_TlsGetValue来解决_TlsGetValue @ 4
警告:通过链接到_GetLastError解决_GetLastError @ 0
警告:通过链接到_LeaveCriticalSection来解决_LeaveCriticalSection @ 4
警告:通过链接到_DeleteCriticalSection来解决_DeleteCriticalSection @ 4