Saturday, October 26, 2013

graphics.h in Ubuntu 13.04


While studying in my final year, I had to deal with Graphics Lab. I was working on a program that used the library file "graphics.h". I tried to compile the program using g++ compiler with following code.

g++ midpointcircle.cpp -lgraph

But unfortunately it didn't work. It produced some kind of error. I googled the error and came to know that graphics.h is not available in the standard g++ library.

So, what's the solution.
You need to install some extra packages.
1. Run the following command in the terminal to install necessary tools.
     sudo apt-get install build-essential


2. Then install some extra packages using the command
  sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev libslang2-dev libasound2 libasound-dev

3. Download the package "libgraph-1.0.2.tar.gz" from the given link :
download.savannah.gnu.org/releases/libgraph/
4. Extract the package to the Home Folder

5. Run the following commands to install the package
cd libgraph-1.0.2
./configure
sudo make
sudo make install

sudo cp /usr/local/lib/libgraph.* /usr/lib


Now the installation is complete.

Try executing the file again
g++ midpointcircle.cpp -lgraph

I hope it works!!!



No comments:

Post a Comment