简体   繁体   English

运行OpenGL而不安装?

[英]Running OpenGL without installing?

I am writing an OpenGL based game. 我正在写一个基于OpenGL的游戏。 It includes just these two libraries: glew, glfw3. 它仅包括以下两个库:glew,glfw3。 In order to run it the user must obviously have OpenGL installed, an assumption which I'd like to bypass. 为了运行它,用户显然必须安装了OpenGL,这是我想绕过的假设。 I've gathered all the appropriate binaries inside the game directory and tried linking to these libraries locally but the compiler claims undefined reference to all their functions. 我已经在游戏目录中收集了所有适当的二进制文件,并尝试在本地链接到这些库,但是编译器声称未定义其所有功能的引用。 Am I doing something wrong or is it just impossible? 我是在做错事还是只是不可能? I'm using Windows but it fails on Linux for the same reason. 我正在使用Windows,但由于相同的原因在Linux上失败。

OpenGL is not a library you install, it's an API that's implemented as part of the driver. OpenGL不是您安装的库,而是作为驱动程序的一部分实现的API。 Your compiler complaining about symbols not resolving is completely unrelated to the situation on the end user's computer. 您的编译器抱怨符号无法解析与最终用户计算机上的情况完全无关。 And in your case it simply sounds that you did not tell the compiler / linker which libraries and API interfaces to link into your program binary; 在您的情况下,听起来只是您没有告诉编译器/链接器要链接到程序二进制文件的库和API接口。 your compiler is hence complaining, that some of the internal references don't redolve. 因此,您的编译器在抱怨一些内部引用没有修改。

So here it goes: OpenGL is not something you ship with your program, it's part of the graphics drivers and your program must use whatever OpenGL version is installed on the user's machine. 这样就可以了:OpenGL不是您的程序附带的东西,它是图形驱动程序的一部分,您的程序必须使用用户计算机上安装的任何OpenGL版本。 For this you dynamically link against libGL.so by passing the compiler-linker option -lGL . 为此,您可以通过传递libGL.so -linker选项-lGL动态链接-lGL

GLEW is a helper library that post-loads dynamically all OpenGL functions not found in the system OpenGL ABI, which hence are not exported through the public symbol table of libGL.so . GLEW是一个帮助程序库,它动态地后加载系统OpenGL ABI中找不到的所有OpenGL函数,因此不会通过libGL.so的公共符号表libGL.so Rather they're to be loaded dynamically using glXGetProcAddress – a rather tedious task. 而是使用glXGetProcAddress动态加载glXGetProcAddress -一个相当繁琐的任务。 Be advised that GLEW has some serious issues when it comes to OpenGL-3 and later core profiles. 请注意,GLEW在OpenGL-3和更高版本的核心配置文件方面存在一些严重问题。

GLFW is a simplistic framework library for setting up a window having an OpenGL context. GLFW是用于设置具有OpenGL上下文的窗口的简化框架库。

GLEW and GLFW are safe to link statically with your program, and I recommend you do that. GLEW和GLFW可以安全地与程序静态链接,建议您这样做。 Instead of using the -l… flag, add libGLEW.a and libGLFW.a to the list of source files / compilation units to be linked. 不用-l…标志,而是将libGLEW.alibGLFW.a添加到要链接的源文件/编译单元列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM