GLFW+Ubuntu20.04安装

1、下载安装包

An OpenGL library | GLFW

这次安装的是3.3.8

2、安装依赖

sudo apt-get install cmake xorg-dev libglu1-mesa-dev

否则cmake会报错,报错如下:

~/opengl/glfw/build$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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 - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Including X11 support
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/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
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
CMake Error at src/CMakeLists.txt:192 (message):
  RandR headers not found; install libxrandr development package


-- Configuring incomplete, errors occurred!
See also "/home/r**/opengl/glfw/build/CMakeFiles/CMakeOutput.log".
See also "/home/r**/opengl/glfw/build/CMakeFiles/CMakeError.log".
r**@r************:~/opengl/glfw/build$ cmake ..
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Including X11 support
CMake Error at src/CMakeLists.txt:192 (message):
  RandR headers not found; install libxrandr development package


-- Configuring incomplete, errors occurred!
See also "/home/r**/opengl/glfw/build/CMakeFiles/CMakeOutput.log".
See also "/home/r**/opengl/glfw/build/CMakeFiles/CMakeError.log".

3、创建build文件夹

r**@r*********:~/opengl/glfw-3.3.8$ mkdir build
r**@r*********:~/opengl/glfw-3.3.8$ cd build

4、编译

(1)cmake

(2)make

~/opengl/glfw-3.3.8/build$ cmake ../
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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 - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.17") found components: doxygen 
-- Using X11 for window creation
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/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
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/r**/opengl/glfw-3.3.8/build
~/opengl/glfw-3.3.8/build$ make
Scanning dependencies of target glfw
[  0%] Building C object src/CMakeFiles/glfw.dir/context.c.o
[  1%] Building C object src/CMakeFiles/glfw.dir/init.c.o
[  2%] Building C object src/CMakeFiles/glfw.dir/input.c.o
[  3%] Building C object src/CMakeFiles/glfw.dir/monitor.c.o
[  4%] Building C object src/CMakeFiles/glfw.dir/vulkan.c.o
[  5%] Building C object src/CMakeFiles/glfw.dir/window.c.o
[  5%] Building C object src/CMakeFiles/glfw.dir/x11_init.c.o
[  6%] Building C object src/CMakeFiles/glfw.dir/x11_monitor.c.o
[  7%] Building C object src/CMakeFiles/glfw.dir/x11_window.c.o
[  8%] Building C object src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[  9%] Building C object src/CMakeFiles/glfw.dir/posix_time.c.o
[ 10%] Building C object src/CMakeFiles/glfw.dir/posix_thread.c.o
[ 10%] Building C object src/CMakeFiles/glfw.dir/glx_context.c.o
[ 11%] Building C object src/CMakeFiles/glfw.dir/egl_context.c.o
[ 12%] Building C object src/CMakeFiles/glfw.dir/osmesa_context.c.o
[ 13%] Building C object src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 14%] Linking C static library libglfw3.a
[ 14%] Built target glfw
Scanning dependencies of target boing
[ 14%] Building C object examples/CMakeFiles/boing.dir/boing.c.o
[ 15%] Building C object examples/CMakeFiles/boing.dir/__/deps/glad_gl.c.o
[ 16%] Linking C executable boing
[ 16%] Built target boing
Scanning dependencies of target gears
[ 17%] Building C object examples/CMakeFiles/gears.dir/gears.c.o
[ 18%] Building C object examples/CMakeFiles/gears.dir/__/deps/glad_gl.c.o
[ 19%] Linking C executable gears
[ 19%] Built target gears
Scanning dependencies of target heightmap
[ 20%] Building C object examples/CMakeFiles/heightmap.dir/heightmap.c.o
[ 21%] Building C object examples/CMakeFiles/heightmap.dir/__/deps/glad_gl.c.o
[ 22%] Linking C executable heightmap
[ 22%] Built target heightmap
Scanning dependencies of target sharing
[ 23%] Building C object examples/CMakeFiles/sharing.dir/sharing.c.o
[ 23%] Building C object examples/CMakeFiles/sharing.dir/__/deps/glad_gl.c.o
[ 24%] Linking C executable sharing
[ 24%] Built target sharing
Scanning dependencies of target particles
[ 25%] Building C object examples/CMakeFiles/particles.dir/particles.c.o
[ 26%] Building C object examples/CMakeFiles/particles.dir/__/deps/tinycthread.c.o
[ 27%] Building C object examples/CMakeFiles/particles.dir/__/deps/getopt.c.o
[ 27%] Building C object examples/CMakeFiles/particles.dir/__/deps/glad_gl.c.o
[ 28%] Linking C executable particles
[ 28%] Built target particles
Scanning dependencies of target simple
[ 29%] Building C object examples/CMakeFiles/simple.dir/simple.c.o
[ 30%] Building C object examples/CMakeFiles/simple.dir/__/deps/glad_gl.c.o
[ 31%] Linking C executable simple
[ 31%] Built target simple
Scanning dependencies of target splitview
[ 32%] Building C object examples/CMakeFiles/splitview.dir/splitview.c.o
[ 32%] Building C object examples/CMakeFiles/splitview.dir/__/deps/glad_gl.c.o
[ 33%] Linking C executable splitview
[ 33%] Built target splitview
Scanning dependencies of target offscreen
[ 34%] Building C object examples/CMakeFiles/offscreen.dir/offscreen.c.o
[ 35%] Building C object examples/CMakeFiles/offscreen.dir/__/deps/glad_gl.c.o
[ 36%] Linking C executable offscreen
[ 36%] Built target offscreen
Scanning dependencies of target wave
[ 36%] Building C object examples/CMakeFiles/wave.dir/wave.c.o
[ 37%] Building C object examples/CMakeFiles/wave.dir/__/deps/glad_gl.c.o
[ 38%] Linking C executable wave
[ 38%] Built target wave
Scanning dependencies of target triangle-vulkan
[ 39%] Building C object tests/CMakeFiles/triangle-vulkan.dir/triangle-vulkan.c.o
[ 40%] Building C object tests/CMakeFiles/triangle-vulkan.dir/__/deps/glad_vulkan.c.o
[ 41%] Linking C executable triangle-vulkan
[ 41%] Built target triangle-vulkan
Scanning dependencies of target tearing
[ 42%] Building C object tests/CMakeFiles/tearing.dir/tearing.c.o
[ 43%] Building C object tests/CMakeFiles/tearing.dir/__/deps/glad_gl.c.o
[ 44%] Linking C executable tearing
[ 44%] Built target tearing
Scanning dependencies of target title
[ 45%] Building C object tests/CMakeFiles/title.dir/title.c.o
[ 45%] Building C object tests/CMakeFiles/title.dir/__/deps/glad_gl.c.o
[ 46%] Linking C executable title
[ 46%] Built target title
Scanning dependencies of target opacity
[ 46%] Building C object tests/CMakeFiles/opacity.dir/opacity.c.o
[ 47%] Building C object tests/CMakeFiles/opacity.dir/__/deps/glad_gl.c.o
[ 48%] Linking C executable opacity
[ 48%] Built target opacity
Scanning dependencies of target clipboard
[ 49%] Building C object tests/CMakeFiles/clipboard.dir/clipboard.c.o
[ 50%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/getopt.c.o
[ 51%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/glad_gl.c.o
[ 51%] Linking C executable clipboard
[ 51%] Built target clipboard
Scanning dependencies of target msaa
[ 51%] Building C object tests/CMakeFiles/msaa.dir/msaa.c.o
[ 52%] Building C object tests/CMakeFiles/msaa.dir/__/deps/getopt.c.o
[ 53%] Building C object tests/CMakeFiles/msaa.dir/__/deps/glad_gl.c.o
[ 54%] Linking C executable msaa
[ 54%] Built target msaa
Scanning dependencies of target glfwinfo
[ 55%] Building C object tests/CMakeFiles/glfwinfo.dir/glfwinfo.c.o
[ 55%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/getopt.c.o
[ 56%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/glad_gl.c.o
[ 57%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/glad_vulkan.c.o
[ 58%] Linking C executable glfwinfo
[ 58%] Built target glfwinfo
Scanning dependencies of target iconify
[ 59%] Building C object tests/CMakeFiles/iconify.dir/iconify.c.o
[ 60%] Building C object tests/CMakeFiles/iconify.dir/__/deps/getopt.c.o
[ 61%] Building C object tests/CMakeFiles/iconify.dir/__/deps/glad_gl.c.o
[ 61%] Linking C executable iconify
[ 61%] Built target iconify
Scanning dependencies of target reopen
[ 62%] Building C object tests/CMakeFiles/reopen.dir/reopen.c.o
[ 63%] Building C object tests/CMakeFiles/reopen.dir/__/deps/glad_gl.c.o
[ 64%] Linking C executable reopen
[ 64%] Built target reopen
Scanning dependencies of target gamma
[ 65%] Building C object tests/CMakeFiles/gamma.dir/gamma.c.o
[ 66%] Building C object tests/CMakeFiles/gamma.dir/__/deps/glad_gl.c.o
[ 67%] Linking C executable gamma
[ 67%] Built target gamma
Scanning dependencies of target monitors
[ 68%] Building C object tests/CMakeFiles/monitors.dir/monitors.c.o
[ 69%] Building C object tests/CMakeFiles/monitors.dir/__/deps/getopt.c.o
[ 70%] Building C object tests/CMakeFiles/monitors.dir/__/deps/glad_gl.c.o
[ 71%] Linking C executable monitors
[ 71%] Built target monitors
Scanning dependencies of target windows
[ 72%] Building C object tests/CMakeFiles/windows.dir/windows.c.o
[ 73%] Building C object tests/CMakeFiles/windows.dir/__/deps/getopt.c.o
[ 74%] Building C object tests/CMakeFiles/windows.dir/__/deps/glad_gl.c.o
[ 75%] Linking C executable windows
[ 75%] Built target windows
Scanning dependencies of target timeout
[ 76%] Building C object tests/CMakeFiles/timeout.dir/timeout.c.o
[ 77%] Building C object tests/CMakeFiles/timeout.dir/__/deps/glad_gl.c.o
[ 78%] Linking C executable timeout
[ 78%] Built target timeout
Scanning dependencies of target inputlag
[ 79%] Building C object tests/CMakeFiles/inputlag.dir/inputlag.c.o
[ 80%] Building C object tests/CMakeFiles/inputlag.dir/__/deps/getopt.c.o
[ 81%] Building C object tests/CMakeFiles/inputlag.dir/__/deps/glad_gl.c.o
[ 82%] Linking C executable inputlag
[ 82%] Built target inputlag
Scanning dependencies of target threads
[ 83%] Building C object tests/CMakeFiles/threads.dir/threads.c.o
[ 84%] Building C object tests/CMakeFiles/threads.dir/__/deps/tinycthread.c.o
[ 84%] Building C object tests/CMakeFiles/threads.dir/__/deps/glad_gl.c.o
[ 85%] Linking C executable threads
[ 85%] Built target threads
Scanning dependencies of target cursor
[ 86%] Building C object tests/CMakeFiles/cursor.dir/cursor.c.o
[ 87%] Building C object tests/CMakeFiles/cursor.dir/__/deps/glad_gl.c.o
[ 88%] Linking C executable cursor
[ 88%] Built target cursor
Scanning dependencies of target empty
[ 89%] Building C object tests/CMakeFiles/empty.dir/empty.c.o
[ 89%] Building C object tests/CMakeFiles/empty.dir/__/deps/tinycthread.c.o
[ 90%] Building C object tests/CMakeFiles/empty.dir/__/deps/glad_gl.c.o
[ 91%] Linking C executable empty
[ 91%] Built target empty
Scanning dependencies of target icon
[ 91%] Building C object tests/CMakeFiles/icon.dir/icon.c.o
[ 92%] Building C object tests/CMakeFiles/icon.dir/__/deps/glad_gl.c.o
[ 93%] Linking C executable icon
[ 93%] Built target icon
Scanning dependencies of target events
[ 94%] Building C object tests/CMakeFiles/events.dir/events.c.o
[ 95%] Building C object tests/CMakeFiles/events.dir/__/deps/getopt.c.o
[ 96%] Building C object tests/CMakeFiles/events.dir/__/deps/glad_gl.c.o
[ 96%] Linking C executable events
[ 96%] Built target events
Scanning dependencies of target joysticks
[ 97%] Building C object tests/CMakeFiles/joysticks.dir/joysticks.c.o
[ 97%] Building C object tests/CMakeFiles/joysticks.dir/__/deps/glad_gl.c.o
[ 98%] Linking C executable joysticks
[ 98%] Built target joysticks
Scanning dependencies of target docs
[100%] Generating HTML documentation
[100%] Built target docs

(3)make install

make install 显示Permission denied,于是sudo make install

~/opengl/glfw-3.3.8/build$ make install
[ 14%] Built target glfw
[ 16%] Built target boing
[ 19%] Built target gears
[ 22%] Built target heightmap
[ 24%] Built target sharing
[ 28%] Built target particles
[ 31%] Built target simple
[ 33%] Built target splitview
[ 36%] Built target offscreen
[ 38%] Built target wave
[ 41%] Built target triangle-vulkan
[ 44%] Built target tearing
[ 46%] Built target title
[ 48%] Built target opacity
[ 51%] Built target clipboard
[ 54%] Built target msaa
[ 58%] Built target glfwinfo
[ 61%] Built target iconify
[ 64%] Built target reopen
[ 67%] Built target gamma
[ 71%] Built target monitors
[ 75%] Built target windows
[ 78%] Built target timeout
[ 82%] Built target inputlag
[ 85%] Built target threads
[ 88%] Built target cursor
[ 91%] Built target empty
[ 93%] Built target icon
[ 96%] Built target events
[ 98%] Built target joysticks
[100%] Generating HTML documentation
[100%] Built target docs
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libglfw3.a
CMake Error at src/cmake_install.cmake:41 (file):
  file INSTALL cannot copy file
  "/home/r**/opengl/glfw-3.3.8/build/src/libglfw3.a" to
  "/usr/local/lib/libglfw3.a": Permission denied.
Call Stack (most recent call first):
  cmake_install.cmake:42 (include)


make: *** [Makefile:86: install] Error 1

sudo make install 后

~/opengl/glfw-3.3.8/build$ sudo make install
[sudo] password for r**: 
[ 14%] Built target glfw
[ 16%] Built target boing
[ 19%] Built target gears
[ 22%] Built target heightmap
[ 24%] Built target sharing
[ 28%] Built target particles
[ 31%] Built target simple
[ 33%] Built target splitview
[ 36%] Built target offscreen
[ 38%] Built target wave
[ 41%] Built target triangle-vulkan
[ 44%] Built target tearing
[ 46%] Built target title
[ 48%] Built target opacity
[ 51%] Built target clipboard
[ 54%] Built target msaa
[ 58%] Built target glfwinfo
[ 61%] Built target iconify
[ 64%] Built target reopen
[ 67%] Built target gamma
[ 71%] Built target monitors
[ 75%] Built target windows
[ 78%] Built target timeout
[ 82%] Built target inputlag
[ 85%] Built target threads
[ 88%] Built target cursor
[ 91%] Built target empty
[ 93%] Built target icon
[ 96%] Built target events
[ 98%] Built target joysticks
[100%] Generating HTML documentation
[100%] Built target docs
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libglfw3.a
-- Installing: /usr/local/include/GLFW
-- Installing: /usr/local/include/GLFW/glfw3native.h
-- Installing: /usr/local/include/GLFW/glfw3.h
-- Installing: /usr/local/lib/cmake/glfw3/glfw3Config.cmake
-- Installing: /usr/local/lib/cmake/glfw3/glfw3ConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/glfw3/glfw3Targets.cmake
-- Installing: /usr/local/lib/cmake/glfw3/glfw3Targets-noconfig.cmake
-- Installing: /usr/local/lib/pkgconfig/glfw3.pc

参考:01 ubuntu 安装 glfw_魔尊moon的博客-CSDN博客_glfw ubuntu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值