Allegro Newbie... Need help!

This is a discussion on Allegro Newbie... Need help! within the Game Programming forums, part of the General Programming Boards category; Okay, I decided I wanted to learn a bit of the Allegro library, since I now have a fair grasp ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    15

    Unhappy Allegro Newbie... Need help!

    Okay, I decided I wanted to learn a bit of the Allegro library, since I now have a fair grasp of atleast the basics of C++. I went to a tutorial and did what it said, and it gave me a ton of Linker errors... I assumed there was something wrong with that tutorial so I went to another-- the same thing happened... This is my code.

    Code:
    #include <allegro.h>
    using namespace std;
    
    int main(int argc,char *argv[])
    {
        allegro_init();
        install_keyboard();
        set_gfx_mode(GFX_AUTODETECT,640,480,0,0); //Sets graphics mode!
        readkey();
        return 0;
    }
    END_OF_MAIN()

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Just to clarify a bit-- i'm using Bloodshed Dev-C++...

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    Did you build the allegro library after downloading it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    6
    Quote Originally Posted by flaran
    Okay, I decided I wanted to learn a bit of the Allegro library, since I now have a fair grasp of atleast the basics of C++. I went to a tutorial and did what it said, and it gave me a ton of Linker errors... I assumed there was something wrong with that tutorial so I went to another-- the same thing happened... This is my code.

    Code:
    #include <allegro.h>
    using namespace std;
    
    int main(int argc,char *argv[])
    {
        allegro_init();
        install_keyboard();
        set_gfx_mode(GFX_AUTODETECT,640,480,0,0); //Sets graphics mode!
        readkey();
        return 0;
    }
    END_OF_MAIN()
    If your using Dev C++. You need to make sure youve downloaded the Allegro dev pack from the auto updater. When you do you have to make sure you copy the the allegro40.dll to your c:\windows\win32 directory.

    After that you have to link allegro to your project. To do that you go up to project - project options. Then click on the parameters tab. Then click on the third collumn. And then add library. then find devcpp\lib\liballeg.a

    If you have already done that then post your errors so that we can better understanding.

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Okay... this is just trying to get it to work...

    Code:
    #include <allegro.h>
    
    int main() 
    {       
     allegro_init();      
     set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
     install_keyboard();
     while(!key[KEY_ESC])
       poll_keyboard();
     allegro_exit();
     return 0;     
    }     
    
    END_OF_MAIN();
    I have it doing what you said... I actually did it by starting the proj as an Allegro static proj. I hope that was alright; anyway, now I have
    Code:
    [Linker error] undefined reference to '_imp_key'
    ld return 1 exit status

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Fixed it!

  7. #7
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    Welcome to allegro
    Woop?

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Haha, I was just trying to get it working so that I could get started learning as soon as I got finished with my text project. I'm starting with a text RPG, and then want to be able to move into simple graphics as seamlessly as possible.

  9. #9
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    Well at least you are taking the proper route and walking before you run. I am making a game in allegro as we speak so if you need some tips or whatever fell free to ask.
    Woop?

  10. #10
    Registered User
    Join Date
    Oct 2005
    Posts
    6
    I myself just started learning allegro a little over a week ago. I bought a book called game programing all in one. Which is pretty much all about allegro. I highly recomend that book if you want to learn about allegro.

  11. #11
    C++ Master
    Join Date
    Oct 2005
    Location
    ProgramLand
    Posts
    15
    Yeah uhh i just started using allegro about...2 hours ago was it? Well i downloaded it i added it to

    c:\winnt\system32

    it works. I added it to the parameters. it works.
    When i add end_of_main() or whatever at the end of the code i keep getting this error in my compiling log:

    multiple definition of 'winMain@16'
    first defined here
    ld returned 1 exit status
    [Build Error] [Project1.exe] error 1

    what can this possibly mean?
    i took time writing all that so plz be helpful thankz!

    I KNOW I KNOW i am a c++ master but this f***ing heat is making me suffer temporary memory loss

    -Cloud
    Last edited by Cloud_909; 10-22-2005 at 09:13 PM.

  12. #12
    Registered User
    Join Date
    Oct 2005
    Posts
    6
    Quote Originally Posted by Cloud_909
    Yeah uhh i just started using allegro about...2 hours ago was it? Well i downloaded it i added it to

    c:\winnt\system32

    it works. I added it to the parameters. it works.
    When i add end_of_main() or whatever at the end of the code i keep getting this error in my compiling log:

    multiple definition of 'winMain@16'
    first defined here
    ld returned 1 exit status
    [Build Error] [Project1.exe] error 1

    what can this possibly mean?
    i took time writing all that so plz be helpful thankz!

    I KNOW I KNOW i am a c++ master but this f***ing heat is making me suffer temporary memory loss

    -Cloud
    For one i think END_OF_MAIN(); has to be in all capitals I think but you probably did that and it all so has to be after the } bracket of your main (). If you did all that try posting your code maybe it is something else.
    Code:
    int main()
    {
          your code
    }
    END_OF_MAIN();

  13. #13
    C++ Master
    Join Date
    Oct 2005
    Location
    ProgramLand
    Posts
    15
    my code looks like this:

    Code:
    #include <allegro.h>
    int main(int argc, char *argv[]) 
    {
    	allegro_init();	
    	install_keyboard();
    	set_color_depth(16);
    	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
    	BITMAP *my_pic = NULL;
    	my_pic = load_bitmap("picture.bmp", NULL);
    	blit(my_pic, screen, 0,0,0,0,480,360);
    	readkey();
    	destroy_bitmap(my_pic);
    	return 0;
    } END_OF_MAIN()
    of course, i copyed this off of a tut website. i got allegro but i get the following error from above...

    semi-colon after END_OF_MAIN() or not it still doesn't work...

  14. #14
    C++ Master
    Join Date
    Oct 2005
    Location
    ProgramLand
    Posts
    15
    Any help??

  15. #15
    Registered User
    Join Date
    Oct 2005
    Posts
    6
    I compiled your code and it work fine for me. Did you get a bmp image for the program to load up? Cause that is what the program does is loads a bitmap. If you dont have a bitmap to load up that could be the problem.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 06:49 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  3. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 02:45 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  5. Now's the time to try Allegro (newbie and pro alike)!
    By Justin W in forum Game Programming
    Replies: 19
    Last Post: 12-23-2001, 07:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21