C Graphics Programming in Ubuntu (how to run c graphics program on ubuntu?? ANswer is here->)
An EasY solution for all those who want to run c graphics program on Ubuntu
libgraph - library providing the TurboC graphics API ( graphics.h) in Linux using SDL.
For using this , you need to follow some simple steps as mentioned below:
First of all, 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
Next you need to install some packages. They are: libsdl-image1.2,libsdl-image1.2-dev,guile-1.8 and guile-1.8-dev. For that run the given command at the terminal:
sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev
Now, download and install libgraph-1.0.2.tar.gz from the link :
http://mirror.veriportal.com/savannah/libgraph/
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 (Return)
sudo make (Return)
sudo make install (Return)
After this you can start your C graphics programming in linux. Now try writing a simple C graphics program by including the header file "graphics.h". You can do the programs as you in TURBO C.
For writing the programs you can use the "gedit" tool in ubuntu. For compiling the programs, navigate to the source program folder and use the following command:
gcc filename.c -lgraph
if u get string conversion error try this:
gcc filename -lgraph -Wno-write-string
if you get this error(/tmp/ccYXvPbQ.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
)
then try this
gcc filename -lstdc++ -lgraph -Wno-write-strings
For executing the program, use the command ./a.out
The error “./a.out: error while loading shared libraries: libgraph.so.1: cannot open shared object file: No such file or directory” can be solved by
sudo cp /usr/local/lib/libgraph.* /usr/lib
Have any problem feel free to post it here.
This comment has been removed by the author.
ReplyDeleteU r a savior. It worked just fine.
ReplyDeleteReally nice post, was very helpful.
Now exploring the power of C graphics in UNIX.
Thank u Vishal. :)
i think it works i did not tried yet .And i liked your answer
ReplyDeletethe http://mirror.veriportal.com/savannah/libgraph/ file you said is not downloading the web page is not opened is there any alternative method please tell me
ReplyDelete@Prasad
ReplyDeletegoto dis link
http://download.savannah.gnu.org/releases/libgraph/
@codegenie
ReplyDeleteur Welcome!!!
sir it is not working it gives error like
ReplyDeletegra.c:1: fatal error: cstdlib: No such file or directory
compilation terminated.
so what can i do
@prasad
ReplyDeletei think u r using cstdlib.h
use stdlib.h
or try "stdlib.h "
Iam getting gollowing error while doing it:
ReplyDeleteReading package lists... Done
Building dependency tree
Reading state information... Done
libsdl-image1.2 is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libsdl-image1.2-dev : Depends: libsdl1.2-dev (>= 1.2.10) but it is not going to be installed
Depends: libtiff4-dev but it is not going to be installed
E: Broken packages