开发者社区> 问答> 正文

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,也不行,有解决办法吗?


展开
收起
优选2 2020-06-05 16:39:31 665 0
1 条回答
写回答
取消 提交回答
  • 找到答案了,原来是写错了,需要使用 -lGL -lGLU,小写变大写。
    ######-l是指定库名,-L是指定搜索库的路径
    ######嗯,谢谢

    2020-06-05 16:39:42
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
使用C++11开发PHP7扩展 立即下载
GPON Class C++ SFP O;T Transce 立即下载
GPON Class C++ SFP OLT Transce 立即下载