c++ compiling errors... very odd!

This is a discussion on c++ compiling errors... very odd! within the C++ Programming forums, part of the General Programming Boards category; Hi, my VC++ 6 is acting wierd. After i try running a few small programs, it gives me this error: ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    11

    c++ compiling errors... very odd!

    Hi, my VC++ 6 is acting wierd. After i try running a few small programs, it gives me this error:

    --------------------Configuration: a - Win32 Debug--------------------
    Linking...
    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
    Debug/a.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

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

    EVEN IF MY PROGRAM IS THIS!

    Code:
    #include <iostream.h>
    
    int main()
    {
    cout << "Hey";
    
    return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Use a console project type, not a windows project type.
    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.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    11
    hm.. works fine after taking your advice.

    Few questions though:

    - Whats the difference between the 2?
    - Why did it work before with WIN32 ?

    Thanks!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    - Whats the difference between the 2?
    console programs start at main()
    windows programs start at winmain()

    - Why did it work before with WIN32 ?
    Huh?
    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.

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    11
    Ah! Ok. But before, when i used WIN32 app, it still worked with this code... but honestly, it really doesnt matter anymore.

    I will use console from now on with console applications

    Also, ive always wondered:

    some people use:

    Code:
    int main(){
        return 0;
    }
    while others use

    Code:
    void main(){
       
    }

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    some people use:

    Code:
    int main(){
        return 0;
    }
    while others use

    Code:
    void main(){
       
    }
    Some people are right, while others are wrong.
    My best code is written with the delete key.

  7. #7
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    void main(): FAQ

    > #include <iostream.h>

    #include <iostream>

    Code:
    #include <iostream>
    
    using namespace std; //Note this
    
    int main()
    {
      cout << "Hey";
      return 0;
    }
    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    11
    OK another Question... How to make a public variable so all functions/structures can access them?

  9. #9
    Registered User
    Join Date
    Mar 2004
    Posts
    2
    Last edited by s@qib; 03-06-2004 at 04:07 PM.

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >How to make a public variable so all functions/structures can access them?
    After you've determined that you really do want this and understand that you have to live with the result, make a global variable:
    Code:
    #include <iostream>
    
    int var; // Everyone can access me!
    
    void foo()
    {
      var++;
    }
    
    void bar()
    {
      std::cout<< var <<endl;
    }
    
    int main()
    {
      var = 10;
      foo();
      bar();
    }
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird errors
    By alexnb185 in forum C Programming
    Replies: 4
    Last Post: 11-22-2007, 10:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11:50 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. compiling errors
    By Jessica in forum C++ Programming
    Replies: 5
    Last Post: 04-03-2002, 08:20 PM
  5. stupid errors i got after compiling!! HELP ME!
    By Leeman_s in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2001, 05:13 PM

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