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
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'
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.
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?
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?