Take a look at this source:
| 1 | #include <allegro.h> |
| 2 | #include <stdio.h> |
| 3 | #include "agup\agup.h" |
| 4 | |
| 5 | MENU file_child[] = |
| 6 | { |
| 7 | { "&New", NULL, NULL, 0, NULL }, |
| 8 | { "&Load", NULL, NULL, 0, NULL }, |
| 9 | { "&Save", NULL, NULL, 0, NULL }, |
| 10 | { "", NULL, NULL, 0, NULL }, |
| 11 | { "&Quit", NULL, NULL, 0, NULL } |
| 12 | }; |
| 13 | |
| 14 | MENU edit_child[] = |
| 15 | { |
| 16 | { "&Resize", NULL, NULL, 0, NULL }, |
| 17 | { "&Tileset", NULL, NULL, 0, NULL }, |
| 18 | { "&Name", NULL, NULL, 0, NULL } |
| 19 | }; |
| 20 | |
| 21 | MENU about_child[] = |
| 22 | { |
| 23 | { "&About", NULL, NULL, 0, NULL }, |
| 24 | { "&Help", NULL, NULL, 0, NULL } |
| 25 | }; |
| 26 | |
| 27 | MENU main_menu[] = |
| 28 | { |
| 29 | { "&File", NULL, file_child, 0, NULL }, |
| 30 | { "&Edit", NULL, edit_child, 0, NULL }, |
| 31 | { "&About", NULL, about_child, 0, NULL } |
| 32 | }; |
| 33 | |
| 34 | DIALOG the_dialog[] = |
| 35 | { |
| 36 | /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ |
| 37 | |
| 38 | { d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, |
| 39 | |
| 40 | { d_menu_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, main_menu, NULL, NULL }, |
| 41 | |
| 42 | { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } |
| 43 | }; |
| 44 | |
| 45 | int main() { |
| 46 | allegro_init(); |
| 47 | set_color_depth(16); |
| 48 | set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); |
| 49 | install_keyboard(); |
| 50 | install_mouse(); |
| 51 | agup_init(agtk_theme); |
| 52 | gui_fg_color = makecol(0, 0, 0); |
| 53 | gui_mg_color = makecol(128, 128, 128); |
| 54 | gui_bg_color = makecol(230, 220, 210); |
| 55 | set_dialog_color (the_dialog, gui_fg_color, gui_bg_color); |
| 56 | do_dialog(the_dialog, -1); |
| 57 | agup_shutdown(); |
| 58 | return 0; |
| 59 | } |
| 60 | END_OF_MAIN() |
All it does is create a menu. However, when I tried to use AGUP, I get a bunch of linker errors:
[Linker error] undefined reference to `agtk_theme'
[Linker error] undefined reference to `agup_init(AGUP_THEME const*)'
..and so on. Is there a library that I can link to my project for agup? Because I cannot seem to find one.
If you have the source version of this library, build it first. Then you should be able to link with it.
I have no idea how to build a library, I've always used DevPaks.
I found an agup devpak, one that included the libagup.a, but I still have the same problem even after linking the library.
Same problem? Or some other problem?
It's fixed. agup is a library written in C, so it was compiled in C. All I have to do is:
extern "C"{ #include <agup.h> }
And it works fine.
That extern "C" should ideally be inside agup.h, so nobody else trips on it. Headers are great for hiding verbiage like this.