Celeb Glow
updates | March 04, 2026

How to add graphics.h header file in gcc compiler?

I want to print a pixel on the screen using C language. When I write code and compile it shows

graphics.h:No such file or directory

I found that gcc doesn't have the "graphics.h" header file.

How can I add graphics.h to the gcc compiler?

1

2 Answers

in your .c file

# include <whatever.h>

the < and > will by default search in /usr/include for the specified files, which is why "stdio.h" always just works because that is found in /usr/include/

in your .c file if you have

# include "whatever.h"

then it will only search in the current folder the .c file resides in at compile time to find whatever.h. So if you did # include "stdio.h" you would get not found, but if you did # include "/usr/include/stdio.h" that would work and is equivalent to # include <stdio.h>.

use gcc -I/path_to_wherever -L/path_to_wherever myprogram.c -o myprogram.x to compile to let gcc know where else to look for your .h files with the -I option and for lib files (.a or .so) with -L

when in doubt, use -I and -L to explicitly tell gcc where the .h file is.

also there's no space after -I or -L when providing the path.

with the above out of the way, you need to have whatever-devel package installed, in whatever folder, which then provides graphics.h and the accompanying shared object libgraphics.so or the static library libgraphics.a. The compiled code to whatever function you use out of graphics.h will exist in either the accompanying .so or .a file that you need to also reference at compile time to create a working executable.

you don't add graphics.h to the compiler, it is an independent piece of code that you reference from yours... you tell gcc to compile your .c file and reference these supporting libraries i.e. graphics.h with -I and -L

your compile line will be something like

gcc myprogram.h -o myprogram.x -I/path_to_graphics.h_location -L/path_to_graphics.so_location -lgraphics

the lowercase -l will say link with whatever library, just like -lm is link with the math library.

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.

Follow bellow stepsenter image description here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy