Compiling graphics codes on CodeBlocks IDE always truncate an error: “Cannot find graphics.h”. This is because graphics.h header file is not available in the library folder of CodeBlocks Compiler. To successfully compile graphics code on CodeBlocks IDE, you have to setup winBGIm library.
How to include graphics.h in CodeBlocks ?
Please follow below steps in sequence to include “graphics.h” in CodeBlocks to successfully compile graphics code on Codeblocks Compiler.
Step 1: To setup “graphics.h” in CodeBlocks, first set up winBGIm graphics library. Download WinBGIm from this link
Step 2: Extract the downloaded file. There will be three files:
- graphics.h
- winbgim.h
- libbgi.a
Step 4: Copy and paste libbgi.a to the lib folder of compiler directory.
Step 5: Open Code::Blocks. Go to Settings >> Compiler >> Linker settings.
Step 6: In that window, click the Add button under the “Link libraries” part, and browse.
Select the libbgi.a file copied to the lib folder in step 4.
Step 7: In right part (Other linker options) paste the commands below
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
Step 8: Click Ok
Done!!!
Note: Now, you can compile any C or C++ program containing graphics.h header file. If you compile C codes, and you still get an error saying: “fatal error: sstream : no such file directory”.
For this issue, change your file extension to .cpp if it is .c
No comments:
Post a Comment