Linking error

This is a discussion on Linking error within the C++ Programming forums, part of the General Programming Boards category; This compiles OK but the linking generates the following errors : - --------------------Configuration: One - Win32 Debug-------------------- Linking... LIBCD.lib(crt0.obj) : ...

  1. #1
    DockyD
    Guest

    Linking error

    This compiles OK but the linking generates the following errors : -

    --------------------Configuration: One - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/One.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    One.exe - 2 error(s), 0 warning(s)

    Code :

    #include "iostream.h"
    #include "allegro.h"
    int main()
    {
    allegro_init();
    install_keyboard();
    //set_gfx_mode(GFX_VGA,320,200,0,0); //Remove "//" if want to use resolution: 320x200 instead of 640x480.
    set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
    set_pallete(desktop_pallete);
    textout_centre(screen, font, "Hello, World!", SCREEN_W/2, SCREEN_H/2, 255);
    readkey();
    return 0;
    }


    Any help?
    Thanks

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    int __cdecl main ()

    or go to settings menu and set __cdecl as default
    calling convetion.

    enjoy.

  3. #3
    DockyD
    Guest

    Linking

    The first suggestion does not seem to work.
    Still get the same error message.
    Not sure where to add your second suggestion (which menu).
    Forgot to mention I'm a newbee and am using VC++6
    Thanks
    Andy

  4. #4
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Code:
    #include "iostream.h"
    should be..
    Code:
    #include <iostream>
    using namespace std;

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    You forgot END_OF_MAIN(); at the end of main

    Code:
    int main()
    {
    return 0;
    }
    END_OF_MAIN();

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    END_OF_MAIN();

  7. #7
    DockyD
    Guest
    Now I'm getting loads of compile errors in the gfx.h header file of Allegro !!!
    Oh dear !!

    ompiling...
    One.cpp
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\draw.h(50) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\draw.h(50) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\draw.h(51) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\draw.h(51) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(168) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(180) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(192) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(192) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(204) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(204) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(213) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(222) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(231) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(231) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(240) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\draw.inl(240) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(29) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(29) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(30) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(30) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(30) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(31) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(31) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(32) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(32) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(32) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(34) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(35) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\fmaths.h(36) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(113 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(113 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(113 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(135 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(135 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(135 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(157 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(157 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(157 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(187 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(187 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(187 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(230 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\platform\al386vc.h(246 ) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(46) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(52) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(148) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(154) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(160) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(160) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(166) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(166) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(172) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(183) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(183) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(194) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\inline\fmaths.inl(194) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(32) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(33) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(47) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(47) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(47) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(50) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(50) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(50) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(53) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(56) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(59) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(62) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(62) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(62) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(65) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(65) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(65) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(65) : error C2872: 'fixed' : ambiguous symbol
    c:\program files\microsoft visual studio\vc98\include\allegro\matrix.h(65) : error C2872: 'fixed' : ambiguous symbol
    etc
    :\program files\microsoft visual studio\vc98\include\allegro\matrix.h(74) : fatal error C1003: error count exceeds 100; stopping compilation
    Error executing cl.exe.

    One.exe - 102 error(s), 0 warning(s)

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Could you post you're entire code please?

  9. #9
    DockyD
    Guest
    This is the One.CPP file : -
    #include <iostream>
    using namespace std;
    //#include "iostream.h"
    #include "allegro.h"
    int main()
    //int __cdecl main ()

    {
    allegro_init();
    install_keyboard();
    //set_gfx_mode(GFX_VGA,320,200,0,0); //Remove "//" if want to use resolution: 320x200 instead of 640x480.
    set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
    set_pallete(desktop_pallete);
    textout_centre(screen, font, "Hello, World!", SCREEN_W/2, SCREEN_H/2, 255);
    readkey();
    return 0;
    }
    END_OF_MAIN();



    Any help will be great. I will check the board later when I get home.
    Thanks

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Code:
    int main() 
    {
    allegro_init();
    install_keyboard(); 
    set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
    set_pallete(desktop_pallete);
    textout_centre(screen, font, "Hello, World!", SCREEN_W/2, SCREEN_H/2, 255);
    readkey();
    return 0;
    }
    END_OF_MAIN();
    Try compiling this

  11. #11
    DockyD
    Guest
    I added this at the front of your code : -
    #include <allegro.h>
    It then compiles ok but when linking gives the following error :-

    --------------------Configuration: One - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/One.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    One.exe - 2 error(s), 0 warning(s)

    Any ideas here as until this is sorted I cannot do any graphics!
    I assume it must be some setting in my project or VC++6 that is missing.

    Thanks
    Andy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 02:17 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

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