Error with GLUT compile in ubuntu [duplicate]

吃可爱长大的小学妹 提交于 2019-11-28 08:21:37

The GCC linker may scan libraries in the order they are on the command line, which means for you it may scan the libraries first and sees no one using them, and therefore you get the errors. To be sure, place the libraries last on the command line:

gcc hw_opengl.cpp -o hw_opengl -lGL -lGLU -lglut
Sudip Das
g++ filename.cpp -lGL -lglut -o exfilename

and then

./exfilename

It is because that xlibmesa-gl-dev and xlibmesa-glu-dev do not make soft link to file libGL.so and libGLU.so, so ld cannot find them to link with your code.

You're missing -lglut.

The correct compilation command is gcc -lGL -lglut -lGLU hw_opengl.cpp -o hw_opengl

xIN3N

Check whether you installed binutils-gold (Gold linker) or not if not, install it and if you've already that then remove it and try at terminal,

g++ sourcefile.cpp -lglut
Julie
g++ -lglut -lGLU -lGL helloWorld.cpp -o helloWorld

g++, not gcc, for cpp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!