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,也不行,有解决办法吗?
找到答案了,原来是写错了,需要使用 -lGL -lGLU,小写变大写。
######-l是指定库名,-L是指定搜索库的路径
######嗯,谢谢
集结各类场景实战经验,助你开发运维畅行无忧