Some still uses Turbo C++ for C++ programming. It is too old IDE and everyone doesn’t like this. Also I use Code::Blocks for C/C++ programming. I have been using TDM-GCC C/C++ compiler and it takes me a day for finding working method to add graphics.h in TDM-GCC compiler. This is why I am going to post here the working method of adding graphics.h in TDM-GCC compiler.
- I have tried with the binaries and source provided at WinBGIm – Borland BGI Graphics Emulation but it was not working. A working source code of WinBGIm is available here. Download this source code so that we could compile it for TDM-GCC compiler. And extract it.
- Now you need to install MSYS to compile the source file to get the binaries. While installing it asks if you have MinGW is installed or not, choose yes and select C:\TDM-GCC-64 as your MinGW installation location (it is the path where you have installed the compiler).
- After finishing the installation process of MSYS open MSYS terminal (it may be in desktop as shortcut or in program list).
- Change the location in MSYS to the path you downloaded the WinBGIm source to and simply run make. For example, if you downloaded the source to C:\path\to\WinBGIm\ after you opened MSYS terminal, you should type these command.
- After that, you will get a compiled libbgi.a and a graphics.h which is ready for use in the same folder.
- Copy paste the libbgi.a in C:\TDM-GCC-64\lib folder and graphics.h in C:\TDM-GCC-64\include.
- Open your IDE and link libbgi.a from the linker option in compiler setting and copy paste -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 in the other linker option. And include graphics.h header file in your code.