c++ - 编译 GLFW 源窗口

标签 c++ opengl makefile cmake glfw

我正在尝试编译 GLFW在 Win7 上使用 CMake + Makefile 和 MinGW。

我遵循的命令序列是使用 cmake 生成构建文件:

$ cmake . -G "MinGW Makefiles"
-- The C compiler identification is GNU 4.8.1
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found Vulkan: C:/VulkanSDK/1.1.77.0/Lib32/vulkan-1.lib
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Looking for dinput.h
-- Looking for dinput.h - not found
-- Looking for xinput.h
-- Looking for xinput.h - not found
-- Performing Test _GLFW_HAS_DEP
-- Performing Test _GLFW_HAS_DEP - Success
-- Performing Test _GLFW_HAS_ASLR
-- Performing Test _GLFW_HAS_ASLR - Success
-- Performing Test _GLFW_HAS_64ASLR
-- Performing Test _GLFW_HAS_64ASLR - Failed
-- Using Win32 for window creation
-- Configuring done
-- Generating done
-- Build files have been written to: `E:/workspace_opengl/PotatoRenderer_CMAKE_tests/libs/glfw`

然后我编译源代码:

$ mingw32-make.exe
[  0%] Building C object src/CMakeFiles/glfw.dir/win32_init.c.obj
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c: In function '_glfwUpdateKeyNamesWin32':
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c:482:42: error: 'MAPVK_VSC_TO_VK' undeclared (first use in this function)
             vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
                                          ^
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c:482:42: note: each undeclared identifier is reported only once for each function it appears in
In file included from c:\mingw\include\windows.h:48:0,
                 from E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_platform.h:65,
                 from E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\internal.h:186,
                 from E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c:28:
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c: In function '_glfwPlatformInit':
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_platform.h:146:38: error: '_WIN32_WINNT_VISTA' undeclared (first use in this function)
     IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),      \
                                      ^
E:\workspace_opengl\PotatoRenderer_CMAKE_tests\libs\glfw\src\win32_init.c:528:14: note: in expansion of macro 'IsWindowsVistaOrGreater'
     else if (IsWindowsVistaOrGreater())
              ^
src\CMakeFiles\glfw.dir\build.make:146: recipe for target 'src/CMakeFiles/glfw.dir/win32_init.c.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/glfw.dir/win32_init.c.obj] Error 1
CMakeFiles\Makefile2:121: recipe for target 'src/CMakeFiles/glfw.dir/all' failed
mingw32-make[1]: *** [src/CMakeFiles/glfw.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

我试着用谷歌搜索了一下,但没有发现任何类似的问题。我也试过 including手动 <Windows.h><Winuser.h>没有运气。知道我做错了什么吗?

提前致谢

最佳答案

您的编译器已过时。使用 MinGW-W64,最容易通过 MSys2 安装 http://www.msys2.org/

关于c++ - 编译 GLFW 源窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51584599/

相关文章:

c++ - #includes 的问题

c++ - 是否有其他方法可以使用条件变量捕获可能遗漏的信号?

opengl - Wavefront *.OBJ 文件中的第三个纹理坐标

c - 如何在没有内核源代码树的情况下构建外部内核模块

c++ - 从用四边形绘制的形状转换为用三角形绘制的形状

c++ - 在容器中存储模板化对象

c++ - 尝试使用 C++ 将着色器应用于 OpenGL 中的顶点数组的问题

java - 使用头文件中定义的常量

qt - "c: Command not found"错误

c++ - 使用 -g 标志编译带有 makefile 的单个 c++ 文件不起作用