error LNK2001: unresolved external symbol _main

This is a discussion on error LNK2001: unresolved external symbol _main within the Game Programming forums, part of the General Programming Boards category; Trying to compile with allegro... i linked the lib file... it compiles but when I click excute (mvc++) it gives ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    27

    error LNK2001: unresolved external symbol _main

    Trying to compile with allegro... i linked the lib file...

    it compiles but when I click excute (mvc++) it gives me that error

    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

  2. #2
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    I don't think allegro is supposed to be with MSVC++

  3. #3
    bobish
    Guest
    yes allegro works with MVC++ it use it with mvc++ my self. Heres some things to check first the proper lib files (alleg.lib and allp.lib(for the release version) or alld.lib (for the debug version) must be included in the project file. Secondly you must have the dll file in the folder the projects in (there is some way around this but puting the dll file in the folder is quicker).

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    27
    Code:
    #include <allegro.h>
    
    // Create memory buffer and palette.
    BITMAP *Buffer;
    PALETTE  *Pal;
    
    int main() 
    { 
     // Initialize Allegro.        
     allegro_init();      
    
     // Where 24 is the color depth in bits.
     set_color_depth(24); 
    
     // Set the resolution to 640 by 480 with SAFE autodetection.
     set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
     
     // Setup the sound routines.
     install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, 0);
     // Installing the keyboard handler.
     install_keyboard();
     // Load the picture from disk into the Buffer.
     Buffer = load_bitmap("MyPicture.bmp", Pal);
    
     // Draw or "flush" buffer onto the screen.
     draw_sprite(screen, Buffer, 0, 0);
    
     // Pause program until escape pressed.
     textout(screen, font, "Press ESCape to quit.", 1, 1, makecol(255,255,255));
     while(! key[KEY_ESC])
       ;
    
     // Shut down and clean up.
     destroy_bitmap(Buffer);
     allegro_exit();
     return 0;
    } // End of main function.
    
    // Some Allegro magic to deal with WinMain().
    END_OF_MAIN();
    C:\Programming\C++\allegro\sheeprpg.cpp(23) : error C2664: 'load_bitmap' : cannot convert parameter 2 from 'struct RGB (*)[256]' to 'struct RGB *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.

    whats wrong now?

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    try allocating for it

    PALETTE *Pal = new PALLETTE;

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    27
    that gives even more erros

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I think its looking for a winmain() not a main(). (or visa versa)

    TO do with the way you made the project, win32 console or win32 app.

    Try a search or look at

    http://www.cprogramming.com/cboard/s...hlight=LNK2001

    and see if Adrianxw solution works in your case.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    More errors or not you still need to point the pointers to something, they can cause memory overwrites and program crashes, among other things, if you dont.

  9. #9
    Unregistered
    Guest
    >>
    error LNK2001: unresolved external symbol _main
    <<

    Add:
    END_OF_MAIN();
    after the end of your main function to resolve this.

  10. #10

  11. #11
    Unregistered
    Guest
    theres an error in that faq Buffer = load_bitmap("MyPicture.bmp", Pal); should be
    Buffer = load_bitmap("MyPicture.bmp", &Pal);

  12. #12
    Registered User
    Join Date
    Jan 2002
    Posts
    27
    Originally posted by Unregistered
    >>
    error LNK2001: unresolved external symbol _main
    <<

    Add:
    END_OF_MAIN();
    after the end of your main function to resolve this.
    if you look carefull enough its already there... after putting the &Pal i get this:

    C:\Programming\C++\allegro\sheeprpg.cpp(20) : error C2664: 'load_bitmap' : cannot convert parameter 2 from 'struct RGB (** )[256]' to 'struct RGB *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.

    this isnt a windows aplliction, i just made a .cpp file and trying to compile it in a empty workspace

  13. #13
    bobish
    Guest
    thats your problem you need to create a new win32 project(non mfc) and then add the source file and compile it.

  14. #14
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    did you include the *.lib files in the project settings dialogue?
    goto Project > Settings Click on the Link tab and where it says Object/Library Modules, goto the very end of that and put in: alld.lib alleg.lib allp.lib

  15. #15
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    C:\Programming\C++\allegro\sheeprpg.cpp
    Cool, a sheep RPG.

    Hope the problem was fixed, I wanna play it when it's done.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 02:01 PM

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