While trying c graphic programming on Ubuntu, I figured out that graphic.h is not a standard C library and it is not supported by gcc compiler. So I am writing this article to explain the process.
If you want to use graphics.h on Ubuntu platform you need to compile and install libgraph. It is the implementation of turbo c graphics API on Linux using SDL.
You can download it from here libgraph
Step by Step Instructions:
- STEP 1: First install build-essential by typing
sudo apt-get install build-essential
- STEP 2: Install some additional packages by typing
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
- STEP 3: Now extract the downloaded libgraph-1.0.2.tar.gz file.
- STEP 4: Goto extracted folder and run following command
./configure make sudo make install sudo cp /usr/local/lib/libgraph.* /usr/lib
Now you can use graphics.h lib using following lines:
int gd = DETECT,gm; initgraph (& gd,& gm,NULL);
Reference: ask ubuntu
This article is contributed by Aakash Tiwari. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Important Notes (Added by a user) : Files from the above-given link did not work for me. There are somethings wrong with them I downloaded files from https://github.com/SagarGaniga/Graphics-Library
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Builtin functions of GCC compiler
- __builtin_inf() functions of GCC compiler
- gcc command in Linux with examples
- Branch prediction macros in GCC
- How to compile 32-bit program on 64-bit gcc in C and C++
- Difference between GCC and G++
- Linux Virtualization : Linux Containers (lxc)
- Difference Between Arch Linux and Kali Linux
- Does C++ compiler create default constructor when we write our own?
- When does compiler create default and copy constructors in C++?
- How to print range of basic data types without any library function and constant in C?
- Unordered Sets in C++ Standard Template Library
- Advanced C++ with boost library
- Inbuilt library functions for user Input | scanf, fscanf, sscanf, scanf_s, fscanf_s, sscanf_s
- The C++ Standard Template Library (STL)
- List in C++ Standard Template Library (STL)
- Deque in C++ Standard Template Library (STL)
- Priority Queue in C++ Standard Template Library (STL)
- Map in C++ Standard Template Library (STL)
- Multimap in C++ Standard Template Library (STL)