Ubuntu下glfw的安装与使用

编译D435出错

CMake Error: The following variables are used in this project,but they are set to NOTFOUND.

第一步,下载glfw

到地址www.glfw.org下载glfw source code:glfw-3.2.1.zip,解压

$unzip glfw-3.2.1.zip -d glfw-3.2.1


第二步,编译安装glfw

1. 安装依赖库,
$sudoapt-get build-dep glfw
$sudo apt-get install cmake xorg-dev libglu1-mesa-dev
2.进入 glfw3-3.x.x 目录,建立glfw-build子目录,
$sudo mkdir glfw-build
3. 进入glfw-build,使用cmake命令生成Makefile
$sudo cmake ../
4. make && make install
$sudo make
$sudo make install

第三步,使用glfw

建立main.cpp 输入下面的代码
[plain] view plain copy
  1. #include
  2. intmain(void)
  3. {
  4. GLFWwindow*window;
  5. /*Initializethelibrary*/
  6. if(!glfwInit())
  7. return-1;
  8. /*CreateawindowedmodewindowanditsOpenGLcontext*/
  9. window=glfwCreateWindow(640,480,"HelloWorld",NULL,NULL);
  10. if(!window)
  11. {
  12. glfwTerminate();
  13. return-1;
  14. }
  15. /*Makethewindow'scontextcurrent*/
  16. glfwMakeContextCurrent(window);
  17. /*Loopuntiltheuserclosesthewindow*/
  18. while(!glfwWindowShouldClose(window))
  19. {
  20. /*Renderhere*/
  21. /*Swapfrontandbackbuffers*/
  22. glfwSwapBuffers(window);
  23. /*Pollforandprocessevents*/
  24. glfwPollEvents();
  25. }
  26. glfwTerminate();
  27. return0;
  28. }

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...