Follow following steps to run graphics programs in ubuntu
Step 1: You need to install the dependencies so that all the required compiler tools gets installed. For that you need to run the given command on the terminal:
If you are getting error after executing above command run following command else goto step 2.
It might give an error in ubuntu 14.04 line package not found. In that case you need to add repository for that execute following command:
Step 2: You
need to install some packages. They are: libsdl-image1.2,
libsdl-image1.2-dev, guile-1.8 and guile-2.0-dev. For that run the given
command at the terminal one by one :
Step 1: You need to install the dependencies so that all the required compiler tools gets installed. For that you need to run the given command on the terminal:
sudo apt-get install build-essential
If you are getting error after executing above command run following command else goto step 2.
It might give an error in ubuntu 14.04 line package not found. In that case you need to add repository for that execute following command:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install guile-2.0-dev
sudo cp -r /usr/include/guile/2.0/* /usr/include/
sudo apt-get install libsdl1.2-dev
sudo apt-get install libsdl-image1.2-dev
sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-image-dev
Step 3: Now, download and install libgraph-1.0.2.tar.gz from the [Official link] [Mirror]:
Download this file in any folder and extract it in the home folder or on the desktop wherever you want.
Open the terminal and navigate to the folder where you have extracted libgraph-1.0.2 with the help of cd command. Install this using the commands given below:
./configure
sudo make
sudo make install
Step 4: At last run following command in terminal :
sudo cp /usr/local/lib/libgraph.* /usr/lib
Step 5: Now you able to run your graphics program in ubuntu
to run your graphics program use following commands:
gcc filename.c -lgraph
./a.out
Sample graphics Code :1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<stdio.h> #include<graphics.h> void main() { int gd=DETECT,gm; detectgraph(&gd,&gm); initgraph(&gd,&gm,""); line(10,10,150,150); delay(5000); closegraph(); } |
No comments:
Post a Comment