今天写了个最简单的Opengl程序,可是发现怎么都有错误,一直提示
/tmp/ccQSf6CG.o:7.cpp:function display(): error: undefined reference to 'gluLook
首先从网上查找解决方法,说可以利用链接动态链接库来解决
我的方法是
g++ 7.cpp -o 7.out -I /usr/lib/i386-linux-gnu/libglut.so.3
/usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGLU.so.1 -lGL
出现的问题更加的多
cc1plus: 警告: /usr/lib/i386-linux-gnu/libglut.so.3: not a directory [默认启用]
/tmp/ccsdnkgf.o:7.cpp:function display(): error: undefined reference to 'glutWireCube'
/tmp/ccsdnkgf.o:7.cpp:function display(): error: undefined reference to 'glutSwapBuffers'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutInit'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutInitDisplayMode'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutInitWindowSize'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutInitWindowPosition'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutCreateWindow'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutReshapeFunc'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutDisplayFunc'
/tmp/ccsdnkgf.o:7.cpp:function main: error: undefined reference to 'glutMainLoop'
没有办法,最后发现很简单,是因为我没有链接到GLU库
g++ -lGL -lGLU -lglut 7.cpp -o 7.out
就没有错误出现了