why winbgim.h not work will with codeblocks?

hello my friends
is the header file winbgim.h is special for complier minGW?
if this right, why when I add it in a project in a codeblocks
the complier give me error such below?
in addition to the same way give errors if i include graphics.h
please help me my friends
thank you
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"iostream"

#include"winbgim.h"
using namespace std;
inline void line22(char st,int num)
{for(int i=0;i<num;i++)
{cout<<st;
 }
cout<<endl;}
//////////////////////
void colr(int col)
{setcolor(col);

}
//////////
void circ(int j,int l,int k,int col )
{circle(j,l,k);
setcolor(col);}
///////////////
int main()
{int graphDriver= DETECT, gmode;
char y;
initgraph(&graphDriver, &gmode, "");
line22('/',60);
line22('/',50);

colr(RED);
circ(0,0,80,RED);
closegraph();
cin>>y;
return 0;}

the Errors that i hate it
||=== animated, Debug ===|
obj\Debug\animated.o||In function `_Z4colri':|
\animated\animated.cpp|12|undefined reference to `_setcolor'|
obj\Debug\animated.o||In function `_Z4circiiii':|
\animated\animated.cpp|17|undefined reference to `_circle'|
\animated\animated.cpp|18|undefined reference to `_setcolor'|
obj\Debug\animated.o||In function `main':|
\animated\animated.cpp|23|undefined reference to `_initgraph'|
\animated\animated.cpp|29|undefined reference to `_closegraph'|
||=== Build finished: 5 errors, 0 warnings ===|

I don't know where you got that header, but it's definitely not part of the standard MinGW distribution.
In any case, the compiler is accepting the header. The one who's complaining is the linker, about not having definitions for some functions. You need to link the import library. I've never seen that header before, so I can't help you there. Maybe someone else has.
helios
thank you for your attention and concern
i`d copied a part from the file to you
if any way to use the graphics.h header file without using borland complier?
thank you
excuse me for my importunity

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// The winbgim library, Version 6.0, August 9, 2004
// Written by:
//      Grant Macklem (Grant.Macklem@colorado.edu)
//      Gregory Schmelter (Gregory.Schmelter@colorado.edu)
//      Alan Schmidt (Alan.Schmidt@colorado.edu)
//      Ivan Stashak (Ivan.Stashak@colorado.edu)
//      Michael Main (Michael.Main@colorado.edu)
// CSCI 4830/7818: API Programming
// University of Colorado at Boulder, Spring 2003


// ---------------------------------------------------------------------------
//                          Notes
// ---------------------------------------------------------------------------
// * This library is still under development.
// * Please see http://www.cs.colorado.edu/~main/bgi for information on
// * using this library with the mingw32 g++ compiler.
// * This library only works with Windows API level 4.0 and higher (Windows 95, NT 4.0 and newer)
// * This library may not be compatible with 64-bit versions of Windows
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
//                          Macro Guard and Include Directives
// ---------------------------------------------------------------------------
#ifndef WINBGI_H
#define WINBGI_H
#include <windows.h>        // Provides the mouse message types
#include <limits.h>         // Provides INT_MAX
#include <sstream>          // Provides std::ostringstream
// ---------------------------------------------------------------------------



// ---------------------------------------------------------------------------
//                          Definitions
// ---------------------------------------------------------------------------
// Definitions for the key pad extended keys are added here.  When one
// of these keys are pressed, getch will return a zero followed by one
// of these values. This is the same way that it works in conio for
// dos applications.
#define KEY_HOME        71
#define KEY_UP          72
#define KEY_PGUP        73
#define KEY_LEFT        75
#define KEY_CENTER      76
#define KEY_RIGHT       77
#define KEY_END         79
#define KEY_DOWN        80
#define KEY_PGDN        81
#define KEY_INSERT      82
#define KEY_DELETE      83
#define KEY_F1          59
#define KEY_F2          60
#define KEY_F3          61
#define KEY_F4          62
#define KEY_F5          63
#define KEY_F6          64
#define KEY_F7          65
#define KEY_F8          66
#define KEY_F9          67

// Line thickness settings
#define NORM_WIDTH      1
#define THICK_WIDTH     3

// Character Size and Direction
#define USER_CHAR_SIZE  0
#define HORIZ_DIR       0
#define VERT_DIR        1


// Constants for closegraph
#define CURRENT_WINDOW -1
#define ALL_WINDOWS -2
#define NO_CURRENT_WINDOW -3

// The standard Borland 16 colors
#define MAXCOLORS       15
enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
              LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE };

// The standard line styles
enum line_styles { SOLID_LINE, DOTTED_LINE, CENTER_LINE, DASHED_LINE, USERBIT_LINE };

// The standard fill styles
enum fill_styles { EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL,
                   BKSLASH_FILL, LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL,
                   WIDE_DOT_FILL, CLOSE_DOT_FILL, USER_FILL };

// The various graphics drivers
enum graphics_drivers { DETECT, CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, HERCMONO,
                        ATT400, VGA, PC3270 };

// Various modes for each graphics driver
enum graphics_modes { CGAC0, CGAC1, CGAC2, CGAC3, CGAHI, 
                      MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
                      EGALO = 0, EGAHI,
                      EGA64LO = 0, EGA64HI,
                      EGAMONOHI = 3,
                      HERCMONOHI = 0,
                      ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
                      VGALO = 0, VGAMED, VGAHI,
                      PC3270HI = 0,
                      IBM8514LO = 0, IBM8514HI };

// Borland error messages for the graphics window.
#define NO_CLICK        -1      // No mouse event of the current type in getmouseclick
enum graph_errors { grInvalidVersion = -18, grInvalidDeviceNum = -15, grInvalidFontNum,
                    grInvalidFont, grIOerror, grError, grInvalidMode, grNoFontMem,
                    grFontNotFound, grNoFloodMem, grNoScanMem, grNoLoadMem,
                    grInvalidDriver, grFileNotFound, grNotDetected, grNoInitGraph,
                    grOk };

// Write modes
enum putimage_ops{ COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT };

// Text Modes
enum horiz { LEFT_TEXT, CENTER_TEXT, RIGHT_TEXT };
enum vertical { BOTTOM_TEXT, VCENTER_TEXT, TOP_TEXT }; // middle not needed other than as seperator
enum font_names { DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANS_SERIF_FONT,
             GOTHIC_FONT, SCRIPT_FONT, SIMPLEX_FONT, TRIPLEX_SCR_FONT,
			 COMPLEX_FONT, EUROPEAN_FONT, BOLD_FONT };
// ---------------------------------------------------------------------------


....
.............
// ---------------------------------------------------------------------------

#endif // WINBGI_H

there is no one can help me in this manner?
why?
help me with one word ?

thanks
Where did you got that? You see, this is a header file. It only contains declarations of functions. You also need the definitions to make it work. As helios said the definitions are inside a library file (usually named winbgi.lib or libwinbgi.a or bgi.lib or libbgi.a).

Do you have a file named like this? If yes, put your headers, winbgi.h and graphics.h in CodeBlocks\MinGW\include\ and then put that lib file in CodeBlocks\MinGW\lib\. Now, go to your project, and select from the menu bar: Project -> Build Options. Then go to the Linker settings tab and hit the Add button of the Link libraries box. Find that lib file and add it to your project. It should be ok now.

If you don't have this file, you can get the whole package from here:

http://www14.brinkster.com/aditsu/console/ (- conio 1.2 and winbgim 3.52)

Oh, note that you may also have to link to libgdi32.a because functions defined there are used too.

EDIT: You may also want to do it like this:

1
2
3
4
//...
cin>>y;
closegraph();
//... 

so that you can actually see what you've drawn... :P

Last edited on
i very thanks to helios and m4ster r0sh
really i thanks my problem was in the linking the header containing library
but there is some thing remain
that is why the screen be like loading some thing and when i click on it became " not responding"
again thanks very mach
Last edited on
Ah, yes. Don't use cin>>y; Do it like this instead:

1
2
3
4
//...
getch();
closegraph();
//...  

Here's an example I found and uploaded to pastebin -> http://pastebin.com/f0yzgLnu
Last edited on
m4ster r0sh
my dear friend i thank you very mach
using getch();
solves the last problem
also i thanks helios
Topic archived. No new replies allowed.