Sunday, March 28, 2010

How to code OpenGL programs on Ubuntu?

After searching for a long time, I've finally found a solution on how to use Code::Blocks to work with OpenGL APIs. 

Code::Blocks is an IDE just like Visual Studio on Windows. Install Code::blocks from the Ubuntu Repository by typing this at the terminal.

sudo apt-get install codeblocks

Once you're done, you need to download files that support OpenGL. You need to install the following package for it to work.

freeglut3 & freeglut3-dev - For GLUT Library. It installs some files into your /usr/include/GL/ folder.

libsdl1.2-dev - For SDL Library. It installs some files into your /usr/include/SDL/ folder.

To install these type the following at the terminal.

sudo apt-get install freeglut3
sudo apt-get install freeglut3-dev 
sudo apt-get install libsdl1.2-dev

Once you're done with this library installation, you should tell the Code::Blocks to link to the correct library for it to be able to execute GLUT/SDL programs. This is how you do it.

1. Open Code:Blocks (You can find this in Applications -> Programming -> Code::Blocks or type codeblocks at your terminal)

2. Go to Settings -> Compiler and Debugger.

3. Open Linker Settings tab. And under "Link Libraries" add "glut" for GLUT, "SDL", "GLU" and "GL" for SDL. 

4. Click OK and you're now done with it. Now your CodeBlocks should be able to compile OpenGL - GLUT/SDL code. Compile a running code to check.

If it didn't work then please comment on this post so that i can help you. 

PS: The whole procedure is to install both GLUT and SDL Libraries. But it is always any one, either GLUT or SDL, that is used. So if you want to install any one of them then skip the instructions that are for the other one. 

1 comment:

  1. Hi Sudarshan,

    Thank you for your visit to http://myinfoland.com and thanks for your comment on Micromax Q7 review. Definitely your analysis will help our readers.

    From your comment I came to your blog. I like your blog design especially. It is good to know that, you are doing blogging while studying. I have impressed with your posts. Do you wish to write guest posts? I have just started a new TechBlog, http://konsole.myinfoland.com. If are willing to write guest articles, please send a mail to kiran.infoland@gmail.com.

    Waiting for a positive reply,

    Thanks & Regards,
    Kiran Kumar

    ReplyDelete