Archived

This topic is now archived and is closed to further replies.

Compiling GLUT Opengl Programs in Linux

This topic is 5741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all.. I currently have Red Hat Linux 7.2 and I am trying to compile a opengl program that I wrote using GLUT. I know that Linux uses MESA, but I am not sure how to link the program to the appropriate libraries as it is compiled. This is easy to do in Win32, but since I am new to linux I am unfamiliar of how to do this. IF anyone could help, I would really appreciate it. Thanks! Bill Blair

Share this post


Link to post
Share on other sites
To link a library using GCC you use -llibname (that''s an L). So, to link OpenGL we use -lGL, GLU is -lGLU, and GLUT is -lGLUT, I''m pretty sure. If you need to link another library, look in one of your library directories to find the actual file. Remove the "lib" from the front and everything after the first period, and then you have a name that can be appended to -l.

Share this post


Link to post
Share on other sites
Okay, great! I think I understand...so the command on the command line looks like this:

>gcc testgl.c -lGL -lGLU -lGLUT


Is that it? or do I just need replace GL, GLU and GLUT with the actual path names. What about object files? Do I need to create that as well? Can I create a make file to do all this?

Thanks for being patient...compiling C programs on LINUX is very new to me...

Thanks!

Share this post


Link to post
Share on other sites
quote:
Original post by jwblair
Will someone please verify the above?

Thanks!



Not sure about the glut part, but the rest is right. Its same even if you use Mesa. Finally you would have to specify path only if the libraries aren''t already in your existing path.

You can create object files like this

gcc -c file1.c
gcc -c file2.c

finally get the executable
gcc file3.c file1.o file2.o -o executable_name

Yes, you can make a file to do all of it - most programs come with a Makefile. "man make" and read a lot of makefiles.

Share this post


Link to post
Share on other sites