编译GLFW源窗口

时间:2018-07-29 21:10:18

标签: c++ opengl makefile cmake glfw

我正在尝试使用带有MinGW的CMake + Makefile在Win7上编译GLFW

我遵循的命令序列是使用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

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

预先感谢

1 个答案:

答案 0 :(得分:1)

您的编译器已过时。使用最容易通过MSys2 http://www.msys2.org/

安装的MinGW-W64