Visual C++ 2010 Problem

I am new to C++. I am trying to create my Hello World program on Visual C++ 2010.

I created a New Project, Win32 Console, and started an empty project.

in the .cpp file I typed;

1
2
3
4
5
6
7
8
9
10
#include <iostream.h>

int main ()
{

	cout<< "Hello world!";


return 0;
}


It will not compile and the errors stated are:

Error 1 error LNK2001: unresolved external symbol _mainCRTStartup C:\Documents and Settings\John\my documents\visual studio 2010\Projects\Test5\Test5\LINK

Error 2 error LNK1120: 1 unresolved externals C:\Documents and Settings\John\my documents\visual studio 2010\Projects\Test5\Debug\Test5.exe 1


I am going to switch to another program that won't have this problem. I heard of DevC++. I would like to use Visual 2010 but this is slowing me down. You are my last resort for Microsoft Visual C++ 2010
Last edited on
Take the semi-colon off the end of line 3.

The problem is yours, not Microsofts.
Last edited on
Sorry about that. That was a typo. I have written the program many times now and I just made a mistake typing it in here.

That said, with that fixed it is still giving me the error. I fear this is a problem you can't solve unless you know visual C++ 2010. I think it has something to do with the settings.
Also:
- it's <iostream> with no .h
- it's std::cout ( or using etc )
- Error 1 refers to the fact that you chose the wrong project template. For a C++ program, select 'Empty Project'

And DO NOT use Dev-C++ it's too old. For a list of IDEs/Compilers see http://www.cplusplus.com/forum/articles/7263/
I rewrote the program with the changes you suggested

1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main ()
{
	cout<< "Hello World";

	return 0;

}


I tryed it also as
1
2
3
4
5
6
7
8
9
10

#include <iostream>
int main ()
{
	std::cout<< "Hello World";

	return 0;

}


Thanks for taking the time to help.

I tryed starting the project as empty as a console and not a concole. I am still getting the same errors.
Is this the only file in your program/project directory?
yes
Have you tried starting it as a C++/General/Empty Project ? I'm thinking starting it as a win32 thing may be the cause of the problem, as it probably expects you to do something with the windows apis.

Edit to add: Indeed, the win32 options for creating a new project create a lot of other things that you don't want. Pick "General" instead of Win32 then Empty Project.
Last edited on
Thank you Pax, that solved the problem I was having.

When I debug I do not get that error.
But tt looks like now Visual C++ can not find the .exe file to run my compiled program. Any suggestions on how to fix that?

Edit:
Seems like there was another post about this same issue
http://www.cplusplus.com/forum/beginner/23614/

I would like to stay with Visual C++ 2010 however.
Last edited on
I am switching back to 2008 Visual C++, My program runs find there.

Problem Solved.
While I agree that 2010 does kind of suck compared to 2008, my reasons for not liking it have nothing to do with what you're doing. Visual Studio gets a brain fart once in a while and refuses to run the built executable. This can happen of both versions. Have you tried rebuilding?
Agree.
For a start, the 2010 help documentation system is shite.. (no other way of putting it)
Last edited on
Topic archived. No new replies allowed.