Is there any Linux based compiler which supports graphics.h
library?
I want to implement graphic programs, so please kindly let me know if there is any such software.
If not then how can I use it?
Is there any Linux based compiler which supports graphics.h
library?
I want to implement graphic programs, so please kindly let me know if there is any such software.
If not then how can I use it?
There are several option available to do graphics programming using Ubuntu.
Using SDL
If you want to use
graphics.h
on Ubuntu platform you need to compile and installlibgraph
. It is the implementation of turbo c graphics API on Linux using SDL.It is not very powerful and suitable for production quality application, but it is simple and easy-to-use for learning purpose.
You can download it from here.
First add the Universe repository (since some required packages are not available in main repository):
Second install build-essential and some additional packages:
For versions prior to 18.04:
For 18.04: From Ubuntu 18.04
guile-2.0
works andlibesd0-dev
is deprecated. For this you need to add repositories ofxenial
insources.list
.Add these lines:
Run
sudo apt-get update
. Then install packages using:Now extract the downloaded
libgraph-1.0.2.tar.gz
file.Go to the extracted folder and run the following command:
Now you can use
#include<graphics.h>
on Ubuntu and the following line in your program:Here is a sample program using
graphics.h
:To compile it use
To run type
Using OpenGL (via GLUT)
Although OpenGL is basically made for 3D programming, drawing 2D shapes gives the basic outline and introduction to OpenGL and gives the idea about how to start drawing objects in OpenGL.
sudo apt-get install freeglut3-dev
.Compile it using
gcc demo.c -o demo -lglut -lGL
Run it using
./demo
If you want to use graphics.h in ubuntu or any other linux distro, then I prefer libxbgi. It can do almost all the things that you expect from the graphics.h for windows. You can download it from here: http://libxbgi.sourceforge.net/
Otherwise if you want to do some high end graphics then you are there for SDL(which is mostly for programming video games) and OpenGL(which is for 3D graphics). You can also use a mixture of the two. One example is the game briquolo(spelling may be wrong).
HAPPY GRAPHICS PROGRAMMING!!