Linux News|Linux Install sidebyside windows|Ubuntu|Linux Help|Installing Apache and php from source

Tuesday, February 7, 2012

Graphics.h in Linux for C and C++|Graphics.h in ubuntu|graphics.h in Linux


Graphics.h in Linux for C and C++

Most of the students in Windows use graphics.h header file in there programs that are written in Borland TurboC. This is a reason that some don’t wanna migrate to Linux well there is a solution for that to. Just follow the steps that i did in Linux/ubuntu.

First install the gcc and g++ compiler by running sudo apt-get build-essential to install necessary compiler tools.

Then, install the following packages:
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

We can install them via Synaptic Package Manager(System->Administration->Synaptic Package Manager) one by one or you can type the following command in the terminal :
sudo apt-get install 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

After this download libgraph-1.0.1 to your Home Folder.
Right click on it and press “Extract here”
Now type in the terminal
./configure
sudo make
sudo make install

This completes the installation.
You can compile your program like this:
g++ test.cpp -o test.o -lgraph
And execute the program by ./test.o

If on compile it gives u an error that says “could not load shared libraries” or something like that just run the following command and it should fix it
sudo cp /usr/local/lib/libgraph.* /usr/lib

An example program(to print a rectangle) :
#include
#include

int main(void)
{
int gd=DETECT, gm=VGAMAX;
initgraph(&gd, &gm, 0);
//moveto(0, 0);
rectangle(50,50,500,200);
closegraph();
return 0;
}

If there are any problems please leave a comment.
You can also see videos posted by Reversehack,this is a very good and clean video you need not to read the above text if you have downloaded the video from here.

Resources: www.itsanimesh.com|http://www.youtube.com/user/ReverseHack

6 comments:

  1. after fixing by sudo cp /usr/local/lib/libgraph.* /usr/lib what i have to type next

    ReplyDelete
  2. If I am not wrong you have to compile and execute your program

    ReplyDelete
  3. sudo: cp/usr/local/lib/libgraph.*/usr/lib COMMAND NOT FOUND !

    ReplyDelete
  4. I’d say that SDL_bgi is much better than libgraph: it’s SDL2-based, more portable, and *much* faster than libgraph. http://libxbgi.sourceforge.net/

    ReplyDelete
    Replies
    1. Now I am realising why to use Borland c compiler old Api's. Need to update curriculum instead of this. But to answer your question I am not sure.

      Delete

ubuntuway.blogspot.com