开发者社区 问答 正文

linux下c++ glut make编译问题? 400 报错

linux下c++ glut make编译问题? 400 报错

一个贪吃蛇程序

make出错,错误如下:

g++ main.o painter.o field.o snake.o game.o -o snake -g -lglut 
/usr/bin/ld: main.o: undefined reference to symbol 'glOrtho'
/usr/bin/ld: note: 'glOrtho' 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
make: *** [snake] Error 1

google了一下,说要在Makefile中添加

USED_LIBS+= glut GL

但是不知道这个该添加在哪,

在g++中加入-L/usr/lib/ 和-LGL -LGLU,也不行,有解决办法吗?


展开
收起
爱吃鱼的程序员 2020-06-02 13:57:46 552 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    找到答案了,原来是写错了,需要使用 -lGL -lGLU,小写变大写。
    ######-l是指定库名,-L是指定搜索库的路径
    ######嗯,谢谢

    2020-06-02 13:58:00 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答分类:
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等