在 Fedora 上设置 OpenGL

发布于 2025-01-06 19:06:38 字数 1420 浏览 0 评论 0原文

我一直在尝试为我的计算机设置(安装并获取正确的库),以便我可以开始图形编程。

我访问过 OpenGL 站点,发现它没有帮助。 我尝试了维基教科书的设置页面,但它有特定于 Debian 和 Debian 类系统的安装信息,我找不到 fedora 的相应内容。

我了解 C 和 python,如果可能的话更愿意使用 C 工作,我确实找到了 PyOpenGL.noarch 并使用 yum 安装了它。

我查找了其他几个网站,但没有找到太多,但我设法安装了 freeglut-devel

我检查并在 /usr/include/GL 文件夹中找到了 GL 库,但是当我尝试运行以下代码{取自wikibooks 网站本身,所以我假设它有效}:

#include <stdio.h> /* printf */
#include <GL/glut.h> /* glut graphics library */
/* 
* Linux c console program 
* gcc f.c -lglut
* ./a.out
* */
main(int argc, char **argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutCreateWindow("red 3D lighted cube");
   printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); /* GL_VERSION = 2.1.2 NVIDIA      195.36.24 */

return 0; 
}

当我执行 gcc -lglut filename.c 时,

我收到以下错误:

/usr/bin/ld: /usr/lib/gcc/i686-redhat-linux/4.6.1/../../../libglut.so: undefined reference to symbol 'glGetString'
/usr/bin/ld: note: 'glGetString' is defined in DSO /usr/lib/libGL.so.1 so try adding it to the linker command line
/usr/lib/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

而且我不知道该怎么做。

如果有基本的分步程序,我们将不胜感激,但如果有任何帮助,我们随时欢迎。

I've been trying to set up (Install and get the correct libraries) for my computer so I could start graphic programming.

I've visited the OpenGL site, and have found it unhelpful.
I tried the Wikibooks' Setting up page, but that has install info specific to Debian and Debian like systems and I couldn't find the corresponding stuff for fedora.

I know C and python and would prefer to work in C if possible, I did find PyOpenGL.noarch and installed it using yum.

I looked up a couple of other sites and didn't find much but I managed to Install freeglut-devel

I checked and found the GL libraries in /usr/include/GL folder but when I try to run the following code{taken from the wikibooks site itself, so I'm assuming it works}:

#include <stdio.h> /* printf */
#include <GL/glut.h> /* glut graphics library */
/* 
* Linux c console program 
* gcc f.c -lglut
* ./a.out
* */
main(int argc, char **argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutCreateWindow("red 3D lighted cube");
   printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); /* GL_VERSION = 2.1.2 NVIDIA      195.36.24 */

return 0; 
}

And when I do gcc -lglut filename.c

I get the following errors:

/usr/bin/ld: /usr/lib/gcc/i686-redhat-linux/4.6.1/../../../libglut.so: undefined reference to symbol 'glGetString'
/usr/bin/ld: note: 'glGetString' is defined in DSO /usr/lib/libGL.so.1 so try adding it to the linker command line
/usr/lib/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

And I have no Idea what to do.

A basic step-by-step procedure would be much appreciated but if any help is always welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷乱花海 2025-01-13 19:06:38

尝试将 -lGL 添加到用于编译它的命令行(这就是错误消息告诉您要做的事情)。

这个问题还建议您还需要 -lGLU

此外,我会将这些库放在使用它们的源文件之后,因此:

gcc filename.c -lglut -lGL -lGLU

而不是:

gcc -lglut -lGL -lGLU filename.c 

有关为什么在 fedora 上收到此消息的更多信息 此处,但基本修复是显式链接缺少的库。

Try adding -lGL to the command line you use to compile it (that's what the error message is telling you to do).

This question also suggests that you'll need -lGLU as well.

Additionally, I would put the libraries after the source files that use them, so:

gcc filename.c -lglut -lGL -lGLU

Instead of:

gcc -lglut -lGL -lGLU filename.c 

There is some more information about why you get this message on fedora here, but the basic fix is to explicitly link the missing library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文