OpenGL/glut/stdc++ 构建错误

2024-02-12

我正在使用 Ubuntu 并尝试使用 synaptic 安装其中包含“GLUT”一词的所有内容以及 SDL 和 opengl 。但一个简单的程序仍然无法编译。它显示了这一点:



opengl1.cpp:(.text+0xe): undefined reference to `glClear'
opengl1.cpp:(.text+0x1a): undefined reference to `glBegin'
opengl1.cpp:(.text+0x2e): undefined reference to `glVertex2i'
opengl1.cpp:(.text+0x33): undefined reference to `glEnd'
opengl1.cpp:(.text+0x38): undefined reference to `glFlush'
/tmp/ccnwQeLu.o: In function `MyInit()':
opengl1.cpp:(.text+0x4c): undefined reference to `glGetString'
opengl1.cpp:(.text+0x57): undefined reference to `std::cout'
opengl1.cpp:(.text+0x5c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x6c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0x78): undefined reference to `glGetString'
opengl1.cpp:(.text+0x83): undefined reference to `std::cout'
opengl1.cpp:(.text+0x88): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x98): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0xc0): undefined reference to `glClearColor'
opengl1.cpp:(.text+0xdf): undefined reference to `glColor3f'
opengl1.cpp:(.text+0xec): undefined reference to `glPointSize'
opengl1.cpp:(.text+0xf8): undefined reference to `glMatrixMode'
opengl1.cpp:(.text+0xfd): undefined reference to `glLoadIdentity'
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccnwQeLu.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
/tmp/ccnwQeLu.o: In function `__static_initialization_and_destruction_0(int, int)':
opengl1.cpp:(.text+0x1cb): undefined reference to `std::ios_base::Init::Init()'
opengl1.cpp:(.text+0x1d0): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccnwQeLu.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
  

如果我使用 g++ 而不是 gcc,我会得到以下结果:



vim opebgl1.cpp
g++ opengl1.cpp -o opengl1 -lGL -lstdc++ -lc -lm
 and then get this :
/tmp/ccCJBuIl.o: In function `MyInit()':
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccCJBuIl.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
  

那么我真正需要什么才能开始在 Ubuntu 中使用 opengl 呢?


将“-lstdc++ -lGL”添加到链接器标志中。 或者尝试像这样编译它:

g++ opengl1.cpp -o opengl1 -lGL -lGLU -lc -lm

(编辑:添加-lGLU,删除-lstdc++)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

OpenGL/glut/stdc++ 构建错误 的相关文章

  • UTF8/UTF16 和 Base64 在编码方面有什么区别

    In c 我们可以使用下面的类来进行编码 System Text Encoding UTF8 System Text Encoding UTF16 System Text Encoding ASCII 为什么没有System Text En
  • ROWNUM 的 OracleType 是什么

    我试图参数化所有现有的 sql 但以下代码给了我一个问题 command CommandText String Format SELECT FROM 0 WHERE ROWNUM lt maxRecords command CommandT
  • 在 LINQ 查询中返回不带时间的日期

    我正在编写一个查询 我想计算按日期联系我们的呼叫中心的次数 看起来很简单 但由于联系日期字段是日期时间字段 我得到了时间 因此当我按联系日期 时间 分组时 每个联系日期实例的计数为 1 所以 我想只按日期分组 而不按时间分组 下面是我用来查
  • Cygwin 下使用 CMake 编译库

    我一直在尝试使用 CMake 来编译 TinyXML 作为一种迷你项目 尝试学习 CMake 作为补充 我试图将其编译成动态库并自行安装 以便它可以工作 到目前为止 我已经设法编译和安装它 但它编译成 dll 和 dll a 让它工作的唯一
  • 使用 Microsoft Graph API 订阅 Outlook 推送通知时出现 400 错误请求错误

    我正在尝试使用 Microsoft Graph API 创建订阅以通过推送通知获取 Outlook 电子邮件 mentions 我在用本文档 https learn microsoft com en us graph api subscri
  • C# 中可空类型是什么?

    当我们必须使用nullable输入 C net 任何人都可以举例说明 可空类型 何时使用可空类型 https web archive org web http broadcast oreilly com 2010 11 understand
  • HttpClient 像浏览器一样请求

    当我通过 HttpClient 类调用网站 www livescore com 时 我总是收到错误 500 可能服务器阻止了来自 HttpClient 的请求 1 还有其他方法可以从网页获取html吗 2 如何设置标题来获取html内容 当
  • 基于范围的 for 循环中的未命名循环变量?

    有没有什么方法可以不在基于范围的 for 循环中 使用 循环变量 同时也避免编译器发出有关未使用它的警告 对于上下文 我正在尝试执行以下操作 我启用了 将警告视为错误 并且我不想进行像通过在某处毫无意义地提及变量来强制 使用 变量这样的黑客
  • Windows下使用GLEW使用OpenGL扩展

    我一直在 Windows 上使用 OpenGL 扩展痛苦的方式 https stackoverflow com questions 14413 using opengl extensions on windows GLEW 是更简单的方法吗
  • 使用安全函数在 C 中将字符串添加到字符串

    我想将文件名复制到字符串并附加 cpt 但我无法使用安全函数 strcat s 来做到这一点 错误 字符串不是空终止的 我确实设置了 0 如何使用安全函数修复此问题 size strlen locatie size nieuw char m
  • 使用 LINQ 查找列表中特定类型的第一个元素

    使用 LINQ 和 C 在元素列表中查找特定类型的第一个项目的最短表示法是什么 var first yourCollection OfType
  • 我的 strlcpy 版本

    海湾合作委员会 4 4 4 c89 我的程序做了很多字符串处理 我不想使用 strncpy 因为它不会终止 我不能使用 strlcpy 因为它不可移植 只是几个问题 我怎样才能让我的函数正常运行 以确保它完全安全稳定 单元测试 这对于生产来
  • 像“1$”这样的位置参数如何与 printf() 一起使用?

    By man I find printf d width num and printf 2 1 d width num 是等价的 但在我看来 第二种风格应该与以下相同 printf d num width 然而通过测试似乎man是对的 为什
  • 网络参考共享类

    我用 Java 编写了一些 SOAP Web 服务 在 JBoss 5 1 上运行 其中两个共享一个类 AddressTO Web 服务在我的 ApplycationServer 上正确部署 一切都很顺利 直到我尝试在我的 C 客户端中使用
  • 将应用程序从 Microsoft Access 迁移到 VB 或 C#.NET

    我目前正试图说服管理层需要将我们的应用程序之一移植到 NET 该应用程序已经发展成为 Access 中的一个庞然大物 SQL 后端 拥有 700 个链接表 650 个表单 子表单 130 个模块和 850 个查询 我几乎知道这样做的所有主要
  • 作为字符串的动态属性名称

    使用 DocumentDB 创建新文档时 我想设置属性名称动态地 目前我设置SomeProperty 像这样 await client CreateDocumentAsync dbs db colls x new SomeProperty
  • 在Linux中使用C/C++获取机器序列号和CPU ID

    在Linux系统中如何获取机器序列号和CPU ID 示例代码受到高度赞赏 Here http lxr linux no linux v2 6 39 arch x86 include asm processor h L173Linux 内核似
  • 在 ASP.NET 中将事件冒泡为父级

    我已经说过 ASP NET 中的层次结构 page user control 1 user control 2 control 3 我想要做的是 当控件 3 它可以是任何类型的控件 我一般都想这样做 让用户用它做一些触发回发的事情时 它会向
  • 窗体最大化时自动缩放子控件

    有没有办法在最大化屏幕或更改分辨率时使 Windows 窗体上的所有内容自动缩放 我发现手动缩放它是正确的 但是当切换分辨率时我每次都必须更改它 this AutoScaleDimensions new System Drawing Siz
  • 为什么 strtok 会导致分段错误?

    为什么下面的代码给出了Seg 最后一行有问题吗 char m ReadName printf nRead String s n m Writes OK char token token strtok m 如前所述 读取字符串打印没有问题 但

随机推荐

  • 如何从 Angular 8 中 primeng p-editor 的工具栏中删除选项卡?

    这是m代码 tabIndex 1 适用于大多数情况 但不适用于选择标签和 ql image 我想从中删除所有选项卡 并希望焦点直接位于编辑器框中而不是工具中
  • EAS 构建找不到 aws-exports

    我有一个使用 AWS Amplify 的 Expo 项目 我目前正在使用 Expo 的 EAS 在移动设备上进行部署 我经常遇到这个错误 Metro encountered an error Unable to resolve module
  • 如何使用react-native-firebase从Firebase动态链接接收查询参数?

    我已经关注了说明 https rnfirebase io dynamic links usage来自官方react native firebase文档和一切 按照说明 工作正常 据我了解 我应该能够在 Firebase 动态链接控制台中创建
  • 如何将excel内部编码的小时数转换为R中的小时数? [复制]

    这个问题在这里已经有答案了 我有一个小时变量存储为 R 中的 Excel 内部编码 参见 https www ablebits com office addins blog 2015 06 23 excel time format now
  • 使用 vba 翻译文本

    可能是一个罕见的请愿书 但问题是这样的 我正在将第三方的 Excel 调整到我的组织中 Excel 是用英语开发的 而我组织的人员只会说西班牙语 我想使用与原始工作表完全相同的代码 我不想碰它 尽管我可以做到 所以我想使用每次出现 msgb
  • 如何使用kso​​ap2设置soap标题 - android

    我需要将肥皂头信息设置为 Web 方法身份验证的一部分 我在用着ksoap2用于调用 NET Web 服务的 API 这是带有请求的肥皂头
  • 用引号将文本包裹在 UILabel 中?

    默认情况下 UILabels 会截断文本 然后在末尾添加省略号 如何将所有文本 包括椭圆 用双引号引起来 Use two UILables 第一个保存文本 加上左引号 第二个仅保存右引号 text that is lon
  • 从基本矩阵估计 T 和 R

    我创建了一个简单的测试应用程序来执行翻译 T 和旋转 R 从基本矩阵进行估计 生成 50 个随机数Points 计算投影点集1 转换Points通过矩阵 R T 计算新的投影点集2 然后计算基础矩阵F 提取必要的矩阵 如E K2 T F K
  • 在 RecyclerView 中隐藏视图

    我有这样的代码 public static class MyViewHolder extends RecyclerView ViewHolder InjectView R id text TextView label public MyVi
  • Double 到 Byte 类型转换错误

    当执行转换时byte to double通过数学运算我得到了预期的结果 执行相同的数学运算来反转值的变化 只要我保持不变 就会得到正确的值double类型 但当最后我转变时double结果返回到bytevalue 转换结果不正确 1 这只是
  • 如果 SQL Server 中另一列不存在值,则按日期季度获取行数和总和组

    我有一些样本数据 Date Status OfferNum Amount 2016 10 30 1 2000 1000 00 2016 08 25 0 2000 1100 00 2016 07 12 0 2001 1200 00 2016
  • 如何为listview设置一个简单的适配器?

    我在将 arraylist 添加到列表视图时遇到问题 将在这里解释我的问题 告诉我这里出了什么问题 我有三个线性布局 在中间布局中我有列表视图 如下面的 xml 文件所示
  • 删除 Flex 中的所有事件侦听器

    如何一次删除所有组件上的所有事件侦听器 特别是当不知道每个组件附加了哪些侦听器时 您可以重写 UIComponent 继承的 mx core FlexSprite 并生成创建的侦听器数组 Doug McCune 发布源代码here http
  • 何时使用查询参数与矩阵参数?

    查询参数 http example com apples order random color blue 矩阵参数 http example com apples order random color blue 什么时候应该使用查询参数而不
  • 如何刷新 Firebase 会话 Cookie

    我正在开发一个使用 Node js Express js 作为后端的 Web 应用程序 我使用 Firebase 进行用户身份验证 并使用 Firebase Admin SDK 管理用户注册等 当用户想要登录时 我使用 Firebase C
  • jqGrid多选,移动到下一页时复选框保留

    如果您看到 jqGrid 演示 http www trirand com blog jqgrid jqgrid html http www trirand com blog jqgrid jqgrid html 部分 高级 gt 多选 当我
  • MariaDB 数据库损坏:引擎中不存在表

    我正在环境设置中 运行 OS XMariaDB 10 0 12 MariaDB Homebrew 我搞砸了安装 所以我从我的设置中完全删除了 MySQL 和 MariaDB 然后重新开始 完成安装 MariaDB 后 我重新导入了我的数据库
  • Excel VBA HTML 嵌套查询选择器

    考虑一下 html 页面的摘录 div class BoxBody span class txt 20 Records found span p style text align right span class txt First Pre
  • Rails:simple_form 中集合所需的属性

    我们正在努力设定required以简单形式 以下设置不起作用 也尝试过 input html gt required true 但效果并不好 正确的设置方法是怎样的required以简单形式 找到了 如果您使用此命令 rails gener
  • OpenGL/glut/stdc++ 构建错误

    我正在使用 Ubuntu 并尝试使用 synaptic 安装其中包含 GLUT 一词的所有内容以及 SDL 和 opengl 但一个简单的程序仍然无法编译 它显示了这一点 opengl1 cpp text 0xe undefined ref