- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add “graphics.h” C/C++ library to gcc compiler in Linux
In this tutorial, we will be discussing a program to understand how to add “graphics.h” C/C++ library to gcc compiler in Linux.
To do this we are required to compile and install the libgraph package.
This includes install build-essential and some external packages
>>sudo apt-get install build-essential >>sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-2.0 guile-2.0-dev libsdl1.2debian libart-2.0-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev libslang2-dev libasound2 libasound2-dev
Then setting the path in the extracted files
>>sudo make install >>sudo cp /usr/local/lib/libgraph.* /usr/lib
Example
#include<stdio.h> #include<stdlib.h> #include<graphics.h> int main(){ int gd = DETECT, gm; initgraph(&gd, &gm, NULL); circle(40, 40, 30); delay(40000); closegraph(); return 0; }
Output
Advertisements