有很多过剩错误
Having many glut errors
>我找到了这段代码,想在我的机器上尝试:
#include <GL/freeglut.h>
static void RenderSceneCB()
{
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}
static void InitializeGlutCallbacks()
{
glutDisplayFunc(RenderSceneCB);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(1024, 768);
glutInitWindowPosition(100, 100);
glutCreateWindow("Tutorial 01");
InitializeGlutCallbacks();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glutMainLoop();
return 0;
}
我得到了这些错误:
G++ 教程01.cpp
/tmp/ccOoXvqJ.o: 在函数 'RenderSceneCB((' 中:
tutorial01.cpp:(.text+0xa(:未定义对"glClear"的引用
tutorial01.cpp:(.text+0xf(:未定义对"glutSwapBuffers"的引用
/tmp/ccOoXvqJ.o: 在函数 'InitializeGlutCallbacks((' 中:
tutorial01.cpp:(.text+0x1f(:未定义对"glutDisplayFunc"的引用
/tmp/ccOoXvqJ.o: 在函数 'main' 中: tutorial01.cpp:(.text+0x43(:
对 'glutInit' tutorial01.cpp:(.text+0x4d( 的未定义引用:
对"glutInitDisplayMode"的未定义引用
教程01.cpp:(.text+0x5c(:未定义的引用
'glutInitWindowSize' tutorial01.cpp:(.text+0x6b(: 未定义的引用
to 'glutInitWindowPosition' tutorial01.cpp:(.text+0x75(: undefined
参考 'glutCreateWindow' 教程01.cpp:(.text+0x8b(: 未定义
参考 'glClearColor' 教程01.cpp:(.text+0x90(: 未定义
引用 'glutMainLoop' collect2:ld 返回 1 个退出状态
我想我已经在我的机器上成功安装了freeglut3-dev。你能告诉我为什么我会收到这么多错误吗?我正在使用 Ubuntu 12.04。
您看到的是链接器错误,即编译器处理的代码已成功转换为编译单元。现在,链接器尝试使可执行的,并且无法捆绑编译单元的松散端,即对 GLUT 和 OpenGL 符号的引用。你必须告诉链接器要查找其他位置,而不仅仅是编译单元和标准库。
由于您的错误消息看起来像 GCC 生成的,我建议您在编译器的命令行中添加-lGL -lglut
。
这些是 Glut 和 OpenGL 的链接器错误。链接器是尝试将所有目标文件链接在一起以获取exe的软件。
您需要将它们(OpenGl和Glut(与您的项目链接起来。谷歌有很多答案=(
我下载了freeglut
并使用 MinGW 编译了我的 Code::blocks 中的代码,我发现您的问题出在库上,您需要链接libopengl32.a
和libfreeglut.a
以便程序可以运行它。
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'