从github下载源码:
本文使用tag-3.4的代码,切换到tag-3.4.
[root@localhost glfw]# git checkout tags/3.4
安装依赖的包:
[root@localhost build]# dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
配置生成Makefile:
[root@localhost build]# cmake …
– Including Wayland support
– Including X11 support
– Found PkgConfig: /usr/bin/pkg-config (found version “1.9.5”)
– Checking for modules ‘wayland-client>=0.2.7;wayland-cursor>=0.2.7;wayland-egl>=0.2.7;xkbcommon>=0.5.0’
– Found wayland-client, version 1.22.0
– Found wayland-cursor, version 1.22.0
– Found wayland-egl, version 18.1.0
– Found xkbcommon, version 1.6.0
– Found X11: /usr/include
– Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so
– Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so - found
– Looking for gethostbyname
– Looking for gethostbyname - found
– Looking for connect
– Looking for connect - found
– Looking for remove
– Looking for remove - found
– Looking for shmat
– Looking for shmat - found
– Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
– Documentation generation requires Doxygen 1.9.8 or later
– Configuring done (0.4s)
– Generating done (0.0s)
– Build files have been written to: /home/storage/bshang-home/glfw
上面提示缺少Doxygen软件,安装doxygen
[root@localhost build]# yum install doxygen
再次进行配置:
[root@localhost build]# cmake -DBUILD_SHARED_LIBS=ON …
– Including Wayland support
– Including X11 support
– Documentation generation requires Doxygen 1.9.8 or later
– Configuring done (0.1s)
– Generating done (0.0s)
– Build files have been written to: /home/storage/bshang-home/glfw
编译安装软件:
[root@localhost glfw]# make
[ 1%] Generating xdg-shell-client-protocol.h
[ 2%] Generating fractional-scale-v1-client-protocol-code.h
[ 2%] Generating fractional-scale-v1-client-protocol.h
…
[ 98%] Built target triangle-vulkan
[100%] Built target window
Install the project…
– Install configuration: “”
– Installing: /usr/local/lib64/libglfw.so.3.4
– Installing: /usr/local/lib64/libglfw.so.3
– Installing: /usr/local/lib64/libglfw.so
– Installing: /usr/local/include/GLFW
– Installing: /usr/local/include/GLFW/glfw3native.h
– Installing: /usr/local/include/GLFW/glfw3.h
– Installing: /usr/local/lib64/cmake/glfw3/glfw3Config.cmake
– Installing: /usr/local/lib64/cmake/glfw3/glfw3ConfigVersion.cmake
– Installing: /usr/local/lib64/cmake/glfw3/glfw3Targets.cmake
– Installing: /usr/local/lib64/cmake/glfw3/glfw3Targets-noconfig.cmake
– Installing: /usr/local/lib64/pkgconfig/glfw3.pc
[root@localhost glfw]#
更新pkg config的搜索路径,以便其他软件可以找到:
[root@localhost glfw]#export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
参考链接:GLFW: Compiling GLFW