gcc and Mesa3D

Started by
3 comments, last by gmonkey 21 years, 5 months ago
i can''t get a simple opengl prog to compile under linux. this is with Mesa3D installed, GLUT in place, samples compiled just fine and run so i know it''s set up more or less properly. if i compile with gcc cube.c -o cube -lglut -lGLU -lGL it compiles with no errors but when i try to run the executable is says ./cube: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory guess i''m not linking it right. i''ve done openGL programming before but never under redhat. what''s the proper way to compile the code?
Advertisement
Before you say -lglut you need to indicate where your GL libraries are at with the -L switch. For example, -Luser/x11r6/lib is how I think you do it on Mandrake.
Megan
Well, if you''re getting to the point to where you can launch your application, then it''s beyond a linking problem. It sounds like you haven''t configured ld properly. LD_LIBRARY_PATH can be set to ''.'' to search the directory ./cube is in (assuming by "in place"). You should probably install glut properly in the future, either by a package (debian: apt-get install libglut3), or /usr/local/lib (you may need to update /etc/ld.so.conf and run ldconfig as root).
if i specify -L then it gives me an error:

/usr/local/lib/libGL.so: undefined reference to `grBufferSwap''
collect2: ld returned 1 exit status

thing is all the demos run with no problems. i guess i''ll try to recompile some of them and see what options are used...
solved my own problem. didn''t bother with the LD_LIBRARY_PATH variable. just specified -Xlinker -R/path/etc in the gcc command line. no more errors. well, not from linking anyway...

This topic is closed to new replies.

Advertisement