Ubuntu安装GLEW

GLEW(OpenGL Extension Wrangler Library)是一个开源的C/C++库,它用于管理OpenGL的扩展功能。GLEW能够查询OpenGL的扩展,确定它们是否可用,并在你的应用程序中动态地使用它们。

在Ubuntu上安装GLEW(OpenGL Extension Wrangler)可以通过以下步骤进行:

apt安装

打开终端(Terminal)。

更新软件包列表:
sudo apt update

安装GLEW库:
sudo apt install libglew-dev
这将安装GLEW的开发库,它包含了必要的头文件和链接库,以便你在Ubuntu上进行OpenGL开发时使用GLEW。
请注意,通过apt安装的GLEW版本可能与最新发布的版本不同步。

CMake安装

如果你需要特定版本或最新版本的GLEW,你可能需要从GLEW的官方网站下载源码并按照其提供的安装说明进行编译和安装。
完成安装后,你可以通过编写一个简单的OpenGL程序来测试GLEW库是否正常工作。

GLEW(OpenGL Extension Wrangler)的官方网站是 http://glew.sourceforge.net/,你可以在这个网站上下载GLEW的源代码并进行安装。

以下是基于源代码安装GLEW的一般步骤:

1:下载压缩包

访问GLEW的官方网站,找到并下载最新版本的GLEW源代码压缩包,通常是一个.zip或.tgz文件。
解压下载的压缩包。这可以通过在终端使用unzip命令(对于.zip文件)或tar -xzf命令(对于.tgz文件)来完成。

wcx@wcx-Ubuntu:~/Downloads$ ls
glew-2.1.0.zip  NVIDIA-Linux-x86_64-550.54.14.run
wcx@wcx-Ubuntu:~/Downloads$ unzip glew-2.1.0.zip 
Archive:  glew-2.1.0.zip
   creating: glew-2.1.0/
   creating: glew-2.1.0/auto/
   creating: glew-2.1.0/auto/core/
   creating: glew-2.1.0/auto/core/gl/
  inflating: glew-2.1.0/auto/core/gl/GL_EXT_texture_array  
  inflating: glew-2.1.0/auto/core/gl/EGL_VERSION_1_5  

2:cmake

wcx@wcx-Ubuntu:~/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX 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
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY
  OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:397 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:40 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/wcx/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild/CMakeFiles/CMakeOutput.log".

报错:Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY
原因:在安装GLEW前一定要先搭建好OpenGL的环境

如果cmake不指定安装位置,这通常会将库文件安装到/usr/local/lib目录,将头文件安装到/usr/local/include/GL目录。

这里指定安装在/usr/local/thirdparty 目录下

wcx@wcx-Ubuntu:~/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/thirdparty ..
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:40 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/wcx/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild

3:make

wcx@wcx-Ubuntu:~/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild$ make -j4
Scanning dependencies of target glew_s
Scanning dependencies of target glew
[ 25%] Building C object CMakeFiles/glew.dir/home/wcx/Desktop/thirtypart/glew-2.1.0/src/glew.c.o
[ 25%] Building C object CMakeFiles/glew_s.dir/home/wcx/Desktop/thirtypart/glew-2.1.0/src/glew.c.o
[ 37%] Linking C static library lib/libGLEW.a
[ 50%] Linking C shared library lib/libGLEW.so
[ 50%] Built target glew
Scanning dependencies of target visualinfo
Scanning dependencies of target glewinfo
[ 62%] Building C object CMakeFiles/visualinfo.dir/home/wcx/Desktop/thirtypart/glew-2.1.0/src/visualinfo.c.o
[ 62%] Built target glew_s
[ 75%] Linking C executable bin/visualinfo
[ 75%] Built target visualinfo
[ 87%] Building C object CMakeFiles/glewinfo.dir/home/wcx/Desktop/thirtypart/glew-2.1.0/src/glewinfo.c.o
[100%] Linking C executable bin/glewinfo
[100%] Built target glewinfo

4:install

wcx@wcx-Ubuntu:~/Desktop/thirtypart/glew-2.1.0/build/cmake/testbuild$ sudo make install
[sudo] password for wcx: 
[ 25%] Built target glew
[ 50%] Built target visualinfo
[ 75%] Built target glewinfo
[100%] Built target glew_s
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/thirdparty/lib/libGLEW.so.2.1.0
-- Installing: /usr/local/thirdparty/lib/libGLEW.so.2.1
-- Installing: /usr/local/thirdparty/lib/libGLEW.so
-- Installing: /usr/local/thirdparty/lib/libGLEW.a
-- Installing: /usr/local/thirdparty/bin/glewinfo
-- Set runtime path of "/usr/local/thirdparty/bin/glewinfo" to ""
-- Installing: /usr/local/thirdparty/bin/visualinfo
-- Set runtime path of "/usr/local/thirdparty/bin/visualinfo" to ""
-- Installing: /usr/local/thirdparty/lib/pkgconfig/glew.pc
-- Installing: /usr/local/thirdparty/include/GL/wglew.h
-- Installing: /usr/local/thirdparty/include/GL/glew.h
-- Installing: /usr/local/thirdparty/include/GL/glxew.h
-- Installing: /usr/local/thirdparty/lib/cmake/glew/glew-targets.cmake
-- Installing: /usr/local/thirdparty/lib/cmake/glew/glew-targets-release.cmake
-- Installing: /usr/local/thirdparty/lib/cmake/glew/glew-config.cmake
-- Installing: /usr/local/thirdparty/lib/cmake/glew/CopyImportedTargetProperties.cmake

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
c++ opengl的glew, # GLEW - The OpenGL Extension Wrangler Library ![](http://glew.sourceforge.net/glew.png) http://glew.sourceforge.net/ https://github.com/nigels-com/glew [![Build Status](https://travis-ci.org/nigels-com/glew.svg?branch=master)](https://travis-ci.org/nigels-com/glew) [![Gitter](https://badges.gitter.im/nigels-com/glew.svg)](https://gitter.im/nigels-com/glew?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Download](https://img.shields.io/sourceforge/dm/glew.svg)](https://sourceforge.net/projects/glew/files/latest/download) ## Downloads Current release is [2.1.0](https://sourceforge.net/projects/glew/files/glew/2.1.0/). [(Change Log)](http://glew.sourceforge.net/log.html) Sources available as [ZIP](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.zip/download) or [TGZ](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.tgz/download). Windows binaries for [32-bit and 64-bit](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0-win32.zip/download). ### Recent snapshots Snapshots may contain new features, bug-fixes or new OpenGL extensions ahead of tested, official releases. ## Build It is highly recommended to build from a tgz or zip release snapshot. The code generation workflow is a complex brew of gnu make, perl and python, that works best on Linux or Mac. For most end-users of GLEW the official releases are the best choice, with first class support. ### Linux and Mac #### Using GNU Make ##### Install build tools Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev libosmesa-dev` RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel` ##### Build $ make $ sudo make install $ make clean Targets: `all, glew.lib (sub-targets: glew.lib.shared, glew.lib.static), glew.bin, clean, install, uninstall` Variables: `SYSTEM=linux-clang, GLEW_DEST=/usr/local, STRIP=` _Note: may need to make **auto** folder_ ####
Ubuntu安装GLEW可以按照以下步骤进行操作。首先,使用命令`apt-cache search glew`来查找GLEW安装包。然后,使用命令`sudo apt-get install libglew-dev`来安装GLEW的开发包。这样就可以解决依赖关系的问题。\[1\] 另外,如果你想安装Mesa和OpenGL的接口,可以按照以下步骤进行操作。首先,使用命令`sudo apt-get install libgl1-mesa-dev`来安装Mesa的开发包。然后,使用命令`sudo apt-get install libglu1-mesa-dev`来安装OpenGL的开发包。最后,使用命令`sudo apt-get install freeglut3-dev`来安装FreeGLUT的开发包。这样就可以完成OpenGL开发环境的安装。\[2\] 如果你在调用shader相关的接口时遇到找不到方法的问题,可以尝试安装GLEW库来解决。安装GLEW库可以使用命令`sudo apt-get install libglew-dev`。安装完成后,你就可以使用GLEW库了。\[3\] #### 引用[.reference_title] - *1* [在Ubuntu下面安装GLEW](https://blog.csdn.net/qq_44072078/article/details/123255464)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Ubuntu安装OpenGL开发环境](https://blog.csdn.net/karizhang/article/details/51434398)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值