Some schools and colleges still use the old Turbo C++ IDE (with compiler) for C/C++ programming. It does not seem surprising. But problems arise if the student has a modern PC running 64-bit(x64) windows operating system. The OS simply refuses to run old 16-bit dos programs (one of them being Turbo C++ IDE whose product line was put on hold after 1994).
Since the Turbo C++ IDE cannot be run on 64-bit(x64) windows OS, the user may choose to use a modern IDE like Microsoft Visual C++, Netbeans (Yes, even for C/C++), Bloodshed Dev C++ (outdated), Eclipse or Codeblocks. However, the problem is still not solved. The header graphics.h and its library are not available with other compilers (not even Borland 5.5). For the purpose of compatibility, a free utility called WinBGIm is available. Follow these steps to get graphics.h working with mingw32 gnu C++ compiler (which is very popular).
- Get an IDE. Some of them are mentioned above. (I use Codeblocks, Netbeans as examples here).
- Get mingw32 GNU C++ compiler from here. OR it is optionally available with Codeblocks IDE here (be sure to check whether the file has mingw in it).
- Install the compiler and the IDE (in this order). Configure your IDE to work with the mingw GNU C++ compiler. Codeblocks if downloaded with mingw automatically sets it as default so that Codeblocks users just have to download and install the setup file. If you use Netbeans (with C/C++ plugin), go to Tools menu > Options > C/C++. Click on Add and paste the address of the bin folder of your compiler (in my case it was C:\MinGW\bin). Additionally you need to install MSYS for netbeans from here. Version 1.0.11 is enough. Configuration is explained in the netbeans community release.
- Download WinBGIm and extract the files.
- Copy the header files (with extension .h) in WinBGIm to the include directory of your compiler. In my case it was C:\MinGW\include.
- Copy the library files in WinBGIm (with extensions like .a, .o) to the lib directory of your compiler. In my case it was C:\MinGW\lib.
- If your IDE can add link libraries (like Codeblocks, Netbeans), add these files which are found in the lib directory mentioned in step 6 to your linker libraries (in same order) :
libbgi, libgdi32, libcomdlg32, libuuid, liboleaut32, libole32.If they are not found, try l instead of lib (it is the letter ‘l’ not one). For Codeblocks, use Project menu > Build Options > Linker Settings tab > Add to add each library one by one. For Netbeans (right click on Project) > Properties > Linker > Libraries entry > …(button) and add the above libraries. If your IDE does not support that, you can add these to your linker command (try the l letter instead of lib if it does not work)-libbgi -libgdi32 -libcomdlg32 -libuuid -liboleaut32 -libole32.An example of a command : g++ bgidemo0.cpp -libbgi -libgdi32 -libcomdlg32 -libuuid -liboleaut32 -libole32 -o bgidemo0.exe
- Write and execute the program as you normally would, including graphics.h header file in your program.
Karan
April 29, 2011
Didn’t work for me.Did the same what u said.
If u have a video tut uploaded in youtube then plz tell me,
R
May 16, 2011
Sorry dont have a vid..
Can u tell me wats the error ??
Akram
July 4, 2011
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/graphics.h:30:59: fatal error: sstream: No such file or directory
Thank you
abhinav sharma
May 4, 2011
great work brother.
R
May 16, 2011
Thank you…
R
June 17, 2011
Thank you so much mate !
Nithin
July 3, 2011
not working
undefines symbols intigraph,circle etc etc
Wolter
July 27, 2011
Perfect, just what I was looking for.
shatrughn
August 12, 2011
getting error…:(
please help…
error: sstream: No such file or directory
R
August 14, 2011
can u post ur full error stack?
Marx Guimarães
January 3, 2012
shatrughn you’re probably using the *.c extension when you are suppose to use *.cpp, that’s was my problem
good luck
zacknov
September 20, 2011
Your article really helped me in making program and write my blog.thank
Fahad
November 5, 2011
HI,,,i am getting this error i dont understand the problem the library libgdi32.a is on place. Help ME
[Error] C:\PROGRA~1\C-FREE~1\mingw\bin\ld.exe: cannot find -lC:\PROGRA~1\C-FREE~1\mingw\lib\libgdi32.a
ekantik atmiya
November 6, 2011
dont find… c/c++ option in Tools>options>….. i use netbeans 7.0
can you specify where can i find it easily
ekantik atmiya
November 6, 2011
dont find… c/c++ option in Tools>options>….. i use netbeans 7.0
can you specify where can i find it easily so please tell me correct way
to deal with this. problem
c function pointer
November 17, 2011
The major benefit of the C corporation that allows the rich (and now you) to make all of the money you want and avoid paying taxes on it is the fact that there is no limit to the business related tax deductions that can be taken by the C corporation. c++
SteBu80
December 28, 2011
Thanks for your article. Using code:blocks, I unfortunately still struggle with the common “sstream not found” – issue despite having added all the libraries in the recommended order. Could it be that the problem lies in the graphics-header file itself? I ask because I also get error messages referring directly to graphics.h, such as “expected ‘(‘ before ‘*’ token) within dozens of code lines, as if that graphics header file wasn’t coded properly.
Is there an alternative to program graphics in C using Codeblocks?
Thanks for your help in advance, I’m becoming really desperate
Ron
January 9, 2012
Hi Rushabh,
This was really helpful. Thanx for sharing your efforts!
Ron