How To Manage C++ Graphics Program In Code Blocks




Problem:

Code Block's GCC Compiler doesn't have dos based graphics library, so when you include graphics.h , it yields error message. This is because there is no such header files in the folder of our compile directory. The solution is given below:

Solution:

  1. Download The File From Here
  2. Extract the downloaded file. You will get three files :
    • graphics.h
    • winbgim.h
    • libbgi.a
  3. Copy and paste graphics.h and winbgim.h files into the include folder
  4. Copy and paste libbgi.a to the lib folder of your compiler directory
  5. Open Code::Blocks. Go to Settings>>Compiler>>Linker Settings
  6. In that window , click the Add button under the "Link libraries" part , and browse and select the libbgi.a
  7. Go to "Other linker options" on the right part and paste these commands:                                                       -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  8. Then Compile Your File Again and you are done.
You May Get Two Windows When You Run The Program . For that you should make the settings as:
  1. Make Project first. When you make new empty file then you cannot change the option.
  2. Go to Projects>>Properties>>Build Target and change the console application into GUI Application.
  3. Then again compile and run. And finally you are done.

No comments