Recently I decided to write gui for allegro, I had choice between c and c++, so i chose c, perhaps for obvious reasons...
And this is my big problem...
I'm working on Visual Studio 2008 and when I compiling code, I get this message:
main.obj : error LNK2019: unresolved external symbol
"struct GUI_INPUT * __cdecl al_gui_input_create(unsigned short,unsigned short,unsigned short,unsigned short)"
(?al_gui_input_create@@YAPAUGUI_INPUT@@GGGG@Z) referenced in function _main
Files:
main.c:
#SelectExpand
1#include <allegro5/allegro.h>
2#include <allegro5/allegro_primitives.h>
3#include <allegro5/allegro_font.h>
4#include <allegro5/allegro_ttf.h>
5
6
7#include "input.h"
8
9int main
( void )
10{
11 al_init( );
12 al_init_font_addon( );
13 al_init_ttf_addon( );
14 al_install_keyboard( );
15
16 ALLEGRO_DISPLAY *display
= al_create_display( 800,
600 );
17 ALLEGRO_EVENT_QUEUE *queue
= al_create_event_queue( );
18 ALLEGRO_TIMER *timer
= al_create_timer( 1.
0 / 60 );
19 ALLEGRO_FONT *font = al_load_font( "DejaVuSans.ttf",
16,
0 );
20
21 struct GUI_INPUT
*input
= al_gui_input_create
( 20,
20,
100,
20 );
22
23 /////////////////
24 ALLEGRO_USTR *string
= al_ustr_new( "" );
25 /////////////////
26
27 bool run
= true;
28 bool redraw
= true;
29
30 al_register_event_source( queue,
al_get_keyboard_event_source( ) );
31 al_register_event_source( queue,
al_get_timer_event_source( timer
) );
32
33 al_start_timer( timer
);
34 while( run
)
35 {
36 ALLEGRO_EVENT event
;
37 al_wait_for_event( queue,
&event
);
38
39 if( event.type
== ALLEGRO_EVENT_TIMER
)
40 {
41 redraw
= true;
42 }
43 else if( event.type
== ALLEGRO_EVENT_KEY_UP
)
44 {
45 if( event.keyboard.keycode
== ALLEGRO_KEY_ESCAPE
)
46 run
= false;
47 }
48 ////////////////////
49 else if( event.type
== ALLEGRO_EVENT_KEY_CHAR
)
50 {
51 if( event.keyboard.unichar
!= 0 )
52 al_ustr_append_chr( string, event.keyboard.unichar
);
53 }
54 ///////////////////
55
56
57 if( redraw
&& al_is_event_queue_empty( queue
) )
58 {
59 al_draw_ustr( font,
al_map_rgb( 255,
255,
255 ),
50,
50,
0, string
);
60 al_flip_display( );
61 al_clear_to_color( al_map_rgb( 0,
0,
0 ) );
62 }
63 }
64}
input.h
#SelectExpand
1#ifndef _al_gui_input
2#define _al_gui_input
3
4#include <allegro5/allegro.h>
5
6struct GUI_INPUT
7{
8 unsigned short startx;
9 unsigned short starty;
10 unsigned short stopx;
11 unsigned short stopy;
12};
13
14struct GUI_INPUT* al_gui_input_create( unsigned short x, unsigned short y, unsigned short width, unsigned short height );
15
16#endif
input.c
#SelectExpand
1#include "input.h"
2
3struct GUI_INPUT
* al_gui_input_create
( unsigned short x,
unsigned short y,
unsigned short width,
unsigned short height
)
4{
5 struct GUI_INPUT
*input
= (struct GUI_INPUT
*)malloc( sizeof( struct GUI_INPUT
) );
6
7 input->startx
= x
;
8 input->starty
= y
;
9 input->stopx
= width
+ x
;
10 input->stopy
= height
+ y
;
11
12 return input
;
13}
Plese, help...
if not, i wrote GUI in C++ ( joke )
=======================
PS:
I'm stupid...
Problem solved