BGI (Borland Graphics Interface) is ancient as is turbo c++ IDE but nevertheless they are still used in our schools and colleges. Plus they do not work in windows environment (support for native DOS has been completely removed in windows vista/7).If you try to compile the source code with including “graphics.h” in code::blocks IDE then is show error because “graphics.h” only run in turbo.For code::blocks you have to setup winBGIm library.
There are many alternative to winBGIm ,But BGI is good for beginners because you don’t have to worry about whole new fancy functions,classes etc.
WinBGIm is BGI graphics library ported to computer by by Michael Main at the University of Colorado.
Before i start, i must tell you that this guide is written in accordance with code::blocks IDE.
Lets get started:
There are many alternative to winBGIm ,But BGI is good for beginners because you don’t have to worry about whole new fancy functions,classes etc.
WinBGIm is BGI graphics library ported to computer by by Michael Main at the University of Colorado.
Before i start, i must tell you that this guide is written in accordance with code::blocks IDE.
Lets get started:
- First download WinBGIm from http://winbgim.codecutter.org/
- Extract it.
- Copy graphics.h and winbgim.h files in include folder of your compiler directory
- Copy libbgi.a to lib folder of your compiler directory
- In code::blocks open Settings >> Compiler and debugger >>linker settings
- click Add button in link libraries part and browse and select libbgi.a file
- In right part (ie. other linker options) paste commands -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
- click Ok
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| #include <graphics.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <conio.h> #include<math.h> #include<dos.h> #include<string.h> #include<iostream> #include<ctime> //using namespace std; int main( void ) { int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver,&gmode, "d:\\tc\\bgi" ); setfillstyle(SOLID_FILL,GREEN); setcolor(GREEN); rectangle(50,50,50+400,50+300); floodfill(51,51,GREEN); setfillstyle(SOLID_FILL,RED); setcolor(RED); circle(250,200,100); floodfill(250,200,RED); getch(); closegraph(); return 0; } |
{ 17 comments... read them below or add one }
error message: fatal error: sstream: No such file or directory
tried the above, got error at (line 30) #include
mingw32-g++.exe -c C:\Users\JVH\Downloads\c++\yash.cpp -o C:\Users\JVH\Downloads\c++\yash.o
In file included from c:\program files (x86)\codeblocks\mingw\include\graphics.h:29:0,
from C:\Users\JVH\Downloads\c++\yash.cpp:1:
c:\program files (x86)\codeblocks\mingw\include\graphics.h:302:40: error: redefinition of 'int right'
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
^
In file included from C:\Users\JVH\Downloads\c++\yash.cpp:1:0:
c:\program files (x86)\codeblocks\mingw\include\graphics.h:302:27: error: 'int right' previously declared here
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
^
C:\Users\JVH\Downloads\c++\yash.cpp: In function 'int main()':
C:\Users\JVH\Downloads\c++\yash.cpp:33:44: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
initgraph(&gdriver,&gmode,"d:\\tc\\bgi");
gives sstream error in graphics.h
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\graphics.h|30|fatal error: sstream: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
after doing this I have an error in graphics .h file line no 224 void getarccoords( arccoordstype *arccoords );
so whai I do now.
??
Please send the download link of code blocks because the i have install code block 16.0 which have no such directories like include or lib any where.
Please send the download link of code blocks because the i have install code block 16.0 which have no such directories like include or lib any where.
I followed the given steps,the code gets complied but fails to run .exe file. kindly guide me through this problem.
but there is still a problem in line 302 of graphics.h header file please give a solution.
I don't have any TC named folder in my C or D drive. I am facing huge problem, plz help me
didnot work . still shows error
The "graphics.h" file has a little error....
Solution to it:
Go to>C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.7.1\include
inside this open "graphics.h" using notepad > go to line no. 302 > there change int right=INT_MAX to int top=INT_MAX
Save the file
That's it...hope it helps
done very same thing
but as soon as i run it shows an error that compgraphics has stopped working
it is not working... when I run my code ...a pop up window appears saying that program has stopped working ....and execution terminate...please guide me regarding this
i am getting an error ld returned 1 exit status
So guys save your program with .cpp extension.
Post a Comment