Alright, I have a very simple program setup, as I am just working my way into real work with Allegro, but every time I try to draw basic primitives I get this:
[Linker error] undefined reference to `_imp__screen'
This results from:
1 | void init_prog( void ) |
2 | { |
3 | allegro_init(); |
4 | install_timer(); |
5 | install_keyboard(); |
6 | install_mouse(); |
7 | } |
8 | |
9 | int main( void ) |
10 | { |
11 | init_prog(); /* initialize everything */ |
12 | |
13 | set_color_depth(16); |
14 | set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0 ); |
15 | |
16 | putpixel( screen, 250, 200, 5 ); /* the problem is here */ |
17 | |
18 | readkey(); |
19 | |
20 | return 0; |
21 | } |
22 | END_OF_MAIN() |
I originally had clear_to_color() instead of putpixel(), and I go the same error.
And help would be appreciated. Once I can get over this slump I think things will progress quickly. Its hard to play around a lot when you dont have any graphics!
How do you link your programs? What parameters you give to the linker?
Remember to include Allegro. And link using -lalleg under MinGW or DJGPP, `allegro-config --libs` under Linux. If after that you are still getting those errors, tell us your Allegro version, compiler [version] and system. The examples work? If not, it is probably you need to compile the library again.
I compiled it as a static library. I'm working with Dev-C++, and my linking options are as follows:
-lalleg_s
-luser32
-lgdi32
-lcomdlg32
-ldinput
-lddraw
-ldxguid
-lwinmm
-ldsound
-lkernel32
-lole32
I was thinking I probably needed to recompile the library. Also, allegro.h is included (sorry, forgot to include that within the snippets I posted). The DX I'm using is DX8 found off the Allegro download section.
I'm working off the most recent stable version of allegro, 4.08 I THINK it was. If it wasn't obvious, I'm working of Windows (XP).
I ran several of the examples (3D boxes, camera, etc) and they seemed to work correctly.
If you want to link with the static version of Allegro, you need to define ALLEGRO_STATICLINK before including the header.
Latest stable is 4.0.3, latest WIP is 4.2.0 beta 4.
Wow, thats an easy fix. Thanks!
Sorry about the version, thats what I get for not checking. It is 4.0.3.