Dev-C++ and Allegro Help

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
Techtronic7
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 23
Joined: Thu Jun 10, 2010 4:17 pm
Programming Language of Choice: C++

Dev-C++ and Allegro Help

Post 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.
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Dev-C++ and Allegro Help

Post by mv2112 »

Try putting:

Code: Select all

#define USE_CONSOLE
at the top of the file.
Techtronic7
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 23
Joined: Thu Jun 10, 2010 4:17 pm
Programming Language of Choice: C++

Re: Dev-C++ and Allegro Help

Post by Techtronic7 »

That didnt work at all. Now everything with an underscore is acting up.
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Dev-C++ and Allegro Help

Post 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?
Techtronic7
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 23
Joined: Thu Jun 10, 2010 4:17 pm
Programming Language of Choice: C++

Re: Dev-C++ and Allegro Help

Post by Techtronic7 »

Win32GUI
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Dev-C++ and Allegro Help

Post 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?
Techtronic7
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 23
Joined: Thu Jun 10, 2010 4:17 pm
Programming Language of Choice: C++

Re: Dev-C++ and Allegro Help

Post by Techtronic7 »

OKOK, I reinstalled everything Dev-C++ and my Allegro DevPak and I found livalleg.a dso it's all good! Thanks!
Post Reply