CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 1999
    Posts
    4

    unresolved external

    Hello, everyone.
    This is Fion.
    I am trying to develop a program in C in the VC++ workstation. Now I am trying to build and debug my
    program. The output of the build is:
    LIBCD.lib(crto.obj):unresolved external symbol -main
    Fatal error 1 unresolved external
    I spend a lot of time on this problem, but I can not find out the answer. If I can not solve this problem,
    I can not continue my project. So it is ergent for me to solve it. Can any body can help me on this problem,
    I will be very appriciate. Thank you very much!!!


  2. #2
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: unresolved external

    Every program you write needs an entry point. In c/c++ this is the main-function. When you write a console application you specifiy this as follows :

    void main(void)
    {
    ...
    }

    When creating a new workspace then select a console application with an empty project.

    When your program is a windowsprogram you can use the wizards which implements a WinMain for you.



  3. #3
    Join Date
    Apr 1999
    Posts
    4

    Re: unresolved external

    Hi, Franky,
    Thank you very much.
    Actually, it is a window program, and I also has a WinMain Function. Is there any other reason for the exist of the bug? Wait for for reply. Say thank to you again!


  4. #4
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: unresolved external

    the declaration of your WinMain should be :

    int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nCmdShow);

    Is WIN32 defined ?

    Use the MFC-wizard. Then you don't have to take care of the WinMain. MFC will do it for you.


  5. #5
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: unresolved external

    Also, make sure that _CONSOLE is NOT defined and that _WINDOWS IS defined.
    These are in the Project settings menu, C/C++ tab, preprocessor settings.



  6. #6
    Join Date
    Apr 1999
    Posts
    4

    Re: unresolved external

    Hi, Gomez
    Thank you a lot. I change the setting under project -preprocessor from _CONSOLE to _WINDOWS
    And my WinMain function looks like this:
    int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpszCmdLine, int nCmdShow )
    {
    MSG msg ;

    if (!hPrevInstance)
    if (!InitApplication( hInstance ))
    return ( FALSE ) ;

    if (NULL == (hTTYWnd = InitInstance( hInstance, nCmdShow )))
    return ( FALSE ) ;

    while (GetMessage( &msg, NULL, 0, 0 ))
    {
    if (!TranslateAccelerator( hTTYWnd, ghAccel, &msg ))
    {
    TranslateMessage( &msg ) ;
    DispatchMessage( &msg ) ;
    }
    }
    return ( (int) msg.wParam ) ;

    }
    After I change my setting of project, it still does not work. Any idea? thank you very much!!!!


  7. #7
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: unresolved external

    To tell you the truth, I am at a loss. Usually when I get in this position I
    look at all of the project options I can find. Check the code generation
    options (I think you have single threaded, I usually use multithreaded,
    dynamic link) and also make sure there is no entry point specified or if
    one is delete it if it is not WinMain. If you decide to bail-out on the bug
    hunt then make a good backup copy of all of your source and use the
    app-wiz to generate a new app. Then replace all of the new stuff with
    what you already have (except for the project files - .dsp, and .dsw )
    and add your files to the project. I know this is kind of a pain but the
    whole project file scene remains a real mystery to me (and everyone I
    know) and I sometimes find that I have to punt and start again. I have
    had to do this so often that I now have a basic project file that I can use
    as a template to make others. I just saved one from the app-wiz and
    deleted nearly everything from it. I kept one source file, a resource
    script, and the pre-compiled header stuff.

    Good Luck and I'm sorry that I can't be more helpful.



  8. #8
    Join Date
    Apr 1999
    Posts
    4

    Re: unresolved external

    Hi, dear Gomez
    Sorry for any troublesome that I bring to you.
    Thank you for your help very much. I will try it later.
    All the best to you, Bye!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured