You are here:

C++/Building problem - Visual C++ 6.0

Advertisement


Question
Hi,

I am new with using visual C++ 6.0, so i tried to build the following hello world program:

#include <iostream>
using namespace std;
int main()
{
   cout << "Hello World!" << endl;
   return 0;
}

I get the following error:
Compiling...
getname.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/p1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

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

I'm not sure what to make of this.
Any help would be great,
Sienne

Answer
Hello Sienne, thank you for the question.

What happened was that when you created the project, you made it a Windows application instead of a console application. The compiler is looking for the WinMain function to execute on startup instead of looking for
main(). Make a new solution, and copy and paste your code into a console application and you will be good to go.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.