While learning Graphics , I need to do some graphics programming as I have done graphics programming in c but as the header file graphics.h is not in C’s standard library and only Turbo C supports it and for that I used windows .
Bus as being a member of FOSS (Free Open Source Society) , Now I am anti-windows so I must find a way to use graphics.h with gcc compiler. I searched the internet and you-tube and find some solutions although none of them were complete so I put all the things here at one place with the possible error and solution which can occur wish this could help you.
In finding an alternate way of doing it and libgraph was just the thing I needed most. ‘libgraph’ is mainly a wrapper around SDL’s libraries that effectively provides most of the functions of graphics.h.
Here is how I set up libgraph in my Debian Sid:
Downloaded the latest version of libgraph from this site:
First installed some libraries that libgraph depends on:
#apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev
(if you are using other distros like Fedora or Suse, packages 4 these distros are also avalable)
Extarcted the tarball
$tar xvzf libgraph-1.0.2.tar.gz
Then inside the folder ran this:
The default destination for the shared library files is /use/local/lib, if this path is not included in your library path (mine was not) then u have to add that manually in your /etc/ld.so.conf
Our installation is complete now. Now I make a simple test.c with these codes:
int gd=DETECT, gm=VGAMAX;
initgraph(&gd, &amp;amp;amp;amp;amp;amp;gm, 0);
[Note: If you see some problem then try to put stdio.h without angled brackets so I’m writing that normally]
Now when we need 2 compile this test.c file we need 2 provide ‘-lgraph’ flag
$gcc test.c -o test.out -lgraph
Congrats, Now you will see a black window with a rectangle in the middle.
If its giving following error….,
“./tes.out: error while loading shared libraries: libgraph.so.1: cannot open shared object file: No such file or directory”
—- When compile libgraph, it writes you where it was installed in. In my case /usr/local/lib.
And then I executed command: export LD_LIBRARY_PATH=”/usr/local/lib”.
If any more problem comes then feel free to mail me and please give the blog link in your mail.
Any suggestions or corrections are most welcome.