You are absolutely right…it’s a pretty old example, and I’d rather have the most basic stuff compile first before I delve into writing a ray tracer or something
For what it’s worth, here’s some more interesting errors I’m getting from another piece of code that further allude to the possibility of this being a library linking issue:
—Begin errors—
/usr/bin/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible /usr/lib/libXmu.so when searching for -lXmu
/usr/bin/ld: skipping incompatible /usr/lib/libXi.so when searching for -lXi
/usr/bin/ld: skipping incompatible /usr/lib/libXext.so when searching for -lXext
/usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
/usr/bin/ld: skipping incompatible /usr/lib/libGLU.so when searching for -lGLU
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.a when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible /usr/lib/libXmu.so when searching for -lXmu
/usr/bin/ld: skipping incompatible /usr/lib/libXi.so when searching for -lXi
/usr/bin/ld: skipping incompatible /usr/lib/libXext.so when searching for -lXext
/usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
/usr/bin/ld: skipping incompatible /usr/lib/libGLU.so when searching for -lGLU
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.a when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible /usr/lib/libXmu.so when searching for -lXmu
/usr/bin/ld: skipping incompatible /usr/lib/libXi.so when searching for -lXi
/usr/bin/ld: skipping incompatible /usr/lib/libXext.so when searching for -lXext
/usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
/usr/bin/ld: skipping incompatible /usr/lib/libGLU.so when searching for -lGLU
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.a when searching for -lglut
/usr/bin/ld: cannot find -lgl
collect2: ld returned 1 exit status
—End errors—
Googling the problem leads to suggestions of having to edit the $LD_LIBRARY_PATH, which is in better circumstances a very bad idea.
Again, before messing with library links and accidentally spawning broken ones, I thought I would have your educated opinion first
This is all running on CentOS 5.4 x64, for what it’s worth.
Please let me know if there’s any information I have to provide.
The “skipping incompatible” messages means that when building a 64 bits executable, it skips 32 bits libraries, which is a good thing. These are not errors, only harmless messages.
“/usr/bin/ld: cannot find -lgl” however means that no libgl library was found. Try with -lGL only, the case is important.
If the linker still can’t find 64 bits libs, it means there are missing
Check is 64 bits libs are installed or available in your repositories :
—Begin errors—
/tmp/ccQlhbql.o: In function makeFloorTexture': dinoshade.c:(.text+0xf3): undefined reference to gluBuild2DMipmaps’
/tmp/ccQlhbql.o: In function extrudeSolidFromPolygon': dinoshade.c:(.text+0x70c): undefined reference to gluNewTess’
dinoshade.c:(.text+0x729): undefined reference to gluTessCallback' dinoshade.c:(.text+0x73f): undefined reference to gluTessCallback’
dinoshade.c:(.text+0x755): undefined reference to gluTessCallback' dinoshade.c:(.text+0x778): undefined reference to gluBeginPolygon’
dinoshade.c:(.text+0x7df): undefined reference to gluTessVertex' dinoshade.c:(.text+0x7f7): undefined reference to gluEndPolygon’
/tmp/ccQlhbql.o: In function redraw': dinoshade.c:(.text+0xdcb): undefined reference to glutGet’
dinoshade.c:(.text+0x14d3): undefined reference to glutSolidSphere' dinoshade.c:(.text+0x1500): undefined reference to glutGet’
dinoshade.c:(.text+0x1539): undefined reference to glutSwapBuffers' /tmp/ccQlhbql.o: In function motion’:
dinoshade.c:(.text+0x1632): undefined reference to glutPostRedisplay' dinoshade.c:(.text+0x16d3): undefined reference to glutPostRedisplay’
/tmp/ccQlhbql.o: In function idle': dinoshade.c:(.text+0x16e3): undefined reference to glutGet’
dinoshade.c:(.text+0x177f): undefined reference to glutPostRedisplay' /tmp/ccQlhbql.o: In function controlLights’:
dinoshade.c:(.text+0x17ca): undefined reference to glutIdleFunc' dinoshade.c:(.text+0x17d9): undefined reference to glutIdleFunc’
dinoshade.c:(.text+0x1902): undefined reference to glutPostRedisplay' /tmp/ccQlhbql.o: In function visible’:
dinoshade.c:(.text+0x1929): undefined reference to glutIdleFunc' dinoshade.c:(.text+0x193f): undefined reference to glutIdleFunc’
/tmp/ccQlhbql.o: In function key': dinoshade.c:(.text+0x1968): undefined reference to glutPostRedisplay’
/tmp/ccQlhbql.o: In function special': dinoshade.c:(.text+0x1980): undefined reference to glutPostRedisplay’
/tmp/ccQlhbql.o: In function main': dinoshade.c:(.text+0x1a06): undefined reference to glutInit’
dinoshade.c:(.text+0x1b23): undefined reference to glutInitDisplayMode' dinoshade.c:(.text+0x1b2d): undefined reference to glutInitDisplayString’
…MANY MORE “undefined reference” errors…
dinoshade.c:(.text+0x1e1f): undefined reference to gluLookAt' dinoshade.c:(.text+0x1eb0): undefined reference to glutMainLoop’
collect2: ld returned 1 exit status
—End errors—
And here’s what yum info libGL.x86_64 reports:
Installed Packages
Name : mesa-libGL
Arch : x86_64
Version : 6.5.1
Release : 7.7.el5
Size : 23 M
Repo : installed
Summary : Mesa libGL runtime libraries and DRI drivers
URL : http://www.mesa3d.org
License : MIT/X11
Description: Mesa libGL runtime libraries and DRI drivers.
I feel like I’m so close to a solution…it’s like one library link away…just not sure how
Again, I’m EXTREMELY grateful for your time. I hope I could return the favor.
Hope you still have the patience to help me slay this beast
New entry point added by GL extensions or after GL 1.2 have to be asked at runtime, they can not be linked during compile/link stages. The OpenGL ABI (application binary interface) is 1.2 under linux.
You can choose, roughly sorted with easiest solutions first :
remove reference to “extended” entry points, super easy but will change the behavior of the program
or use GLEW/Glee, easy
or do the right thing to grab a function pointer at runtime with glXGetProcAddress, which is more involved
Another solution. Since this is just a quick GL test and and you just want it to work, look at what your libGL is advertising for PolygonOffset, and just change the code to use that:
nm -Do /usr/lib64/libGL.so | grep glPolygonOffset
Also, typically you want to specify libraries in order of highest to lowest, like this: