Page 1 of 1

Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 4:36 pm
by Techtronic7
Hello all. Im getting started with Allegro and im using Dev-C++, seeing as how it is my compiler of choice. I was following a tutorial on Allegro and C++ by Lusikkamage on youtube and I followed most of what she said to type (I shortened some comments) and I get a bunch of linker errors on compiling. This is the code I have:

Code: Select all

#include <allegro.h>

int main()
{
    //Allegro Initialization
    allegro_init();
    install_keyboard();
    install_timer();
    install_mouse();
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, 0 );
    set_color_depth( 16 );
    bool fullscreen = false;
    if(fullscreen == true) //For fullscreen
    {
                  set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
    }
    else
        set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    BITMAP *buffer = create_bitmap( 640, 480 );
    
    //Main game loop
    while ( !key[KEY_ESC] )
    {
          rectfill( buffer, 0, 0, 640, 480, makecol(255, 0, 0));
          //Draw rectangle
          blit( buffer, screen, 0, 0, 0, 0, 640, 480 );
          clear_bitmap( buffer );
    }
    //Free memory of bitmap
    destroy_bitmap( buffer );
    return 0;
}
END_OF_MAIN();
Am I doing it wrong? I have already installed the DevPak of Allegro and looked for a reason for my troubles. My search gave me a few things to put into the linker and now im stuck with one main error,
[Linker error] undefined reference to '_WinMain'
I have no idea what Im doing wrong. Could someone please help me. And as for learning Allegro online, Im going a day after posting this to get a book.

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 4:47 pm
by mv2112
Try putting:

Code: Select all

#define USE_CONSOLE
at the top of the file.

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 4:54 pm
by Techtronic7
That didnt work at all. Now everything with an underscore is acting up.

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 4:56 pm
by mv2112
Techtronic7 wrote:That didnt work at all. Now everything with an underscore is acting up.
What type of project did you make? Win32? Console?

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 5:03 pm
by Techtronic7
Win32GUI

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 5:13 pm
by mv2112
Techtronic7 wrote:Win32GUI
It works for me. You dont need the #define console. Make sure your linking against allegro correctly. Go into Project Options->Parameters->Linker and Click Add Library or Object and go into the allegro directory and add liballeg.a. Also, did you download the correct distro for your compiler?

Re: Dev-C++ and Allegro Help

Posted: Thu Jun 10, 2010 7:49 pm
by Techtronic7
OKOK, I reinstalled everything Dev-C++ and my Allegro DevPak and I found livalleg.a dso it's all good! Thanks!