CEG's Linux User Group

  • Increase font size
  • Default font size
  • Decrease font size
Home Tutorials Installing graphics libraries in ubuntu

Installing graphics libraries in ubuntu

E-mail Print
User Rating: / 1
PoorBest 

Running graphics programs in turboc in windows is no big deal. But in Ubuntu, gcc does not come pre-installed with the graphic libraries. You can install the necessary packages however, and do your graphics programs in ubuntu as well. Just follow these steps:

1. Open Terminal and type sudo apt-get install build-essential to install all necessary compiler tools.

2. Install the following packages(Dont get baffled by the long list. Installing them is quite simple) :

libsdl-image1.2
libsdl-image1.2-dev
guile-1.8
guile-1.8-dev
libsdl1.2debian-arts
libartsc0-dev
libaudiofile-dev
libesd0-dev
libdirectfb-dev
libdirectfb-extra
libfreetype6-dev
libxext-dev
x11proto-xext-dev
libfreetype6(upgrade)
libaa1
libaa1-dev
libslang2-dev
libasound2
libasound-dev

You can install them in one step by typing sudo apt-get install followed by each of the above package names seperated by a space. If you are asked to uninstall some existing packages, do so or if some of the packages are reported as not available, dont mind and keep proceeding.

3. Click on this link and download the archive :http://download.savannah.nongnu.org/releases/libgraph/libgraph-1.0.1.tar.gz
For simplicity download this to your Home folder.

4. Go to your Home folder. Extract the contents of the archive by right clicking the archive libgraph-1.0.1.tar.gz and select "Extract here". The folder libgraph-1.0.1 will be extracted.

5. Now come back to Terminal and type cd libgraph-1.0.1

6. Type the following in order, one after the other:

./configure
sudo make
make install


7. Hurray! The installation is over.

8. Here is a sample program for you:

#include
#include
int main()
{
int gd=DETECT, gm;
initgraph(&gd,&gm,"");
circle(150,200,50);
getch();
closegraph();
}

Lets say you save the file as circle.c

9. Now compile the file by typing cc circle.c -lgraph . Note that the -lgraph flag is very important and cannot be omitted.

10. Type ./a.out and you have your output in a seperate window.

Screenshot-1

 


Tested on ubuntu 8.10 Intrepid.


Reference : http://sector-zero.blogspot.com/2007/07/graphicsh-in-gnulinux.html

Last Updated on Thursday, 11 March 2010 23:39  
Please register or login to add your comments to this article.