opens then exited with code 0 (0x0)

Pages: 12
yes, I tried double-clicking the exe and ran from the run dialog, the only thing I have not tried is to run from the command prompt - I hesitate since this it not an issue with earlier builds of this program. I can run a saved build right now and it works fine.
Post your exact code.
it has not changed with the exception of int t = 0; versus int t;

edit: I created a new project, put the exact same code in it and it runs fine. why won't it run in the commented file?
Last edited on
SOLVED (partial):

VS2008, create new project, project type Visual C++, template:Win32 Console Application, Win32 App wizard --> next, console application type, additional options --> empty project, finished

+5 points for the nice hacking approach to a solution, I cannot explain to you why this works but is does.

And for everyone forever after that has this problem, forget all those suggestions to add strange lines of text to your program, and breaks before return 0, or missing libraries.
Last edited on
I think this is why people say learn the language THEN go deal with an IDE if you so desire.
follow-up, the simple solution works but scaling to my full library results in error error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, I saw this in several other threads and tried these:



- wWinMainCRTStartup as entry point in the linker properties http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/14e85604-6929-4707-a22e-8cdf596926a6
- set the linker to "Windows" (same thread as above)
- Right click on solution name->Add->Existing Item->file with main (same thread as above)
- #include <tchar.h> http://stackoverflow.com/questions/4845410/error-lnk2019-unresolved-external-symbol-main-referenced-in-function-tmainc
- try Project + properties, C/C++, Code generation, Buffer security check = No http://social.msdn.microsoft.com/Forums/hi-IN/vclanguage/thread/e2ea62c3-beb3-47a4-8963-60b799e3375a
- Options: C/C++, Code generation, Runtime library=/MTd; C/C++, Code generation, Basic Runtime Checks=default; C/C++, Code generation, Buffer security check=No; Linker, Advanced, Entry Point=main http://social.msdn.microsoft.com/Forums/hi-IN/vclanguage/thread/e2ea62c3-beb3-47a4-8963-60b799e3375a
- commented out headers in main.cpp except 'using namespace std' and #include <iostream> - results in cascading and snowballing error from functions that referencing those headers

have not tried yet
- create new project with Win32 Windows application template http://social.msdn.microsoft.com/Forums/ar-SA/vcgeneral/thread/105a366f-c38d-4c1c-9278-eca64589e7ca and http://social.msdn.microsoft.com/Forums/zh/Vsexpressvc/thread/341780c2-162e-4b36-9402-283c0cf7c0ac
- use int main() (not sure what they mean, file name or main function name) http://social.msdn.microsoft.com/Forums/zh/Vsexpressvc/thread/341780c2-162e-4b36-9402-283c0cf7c0ac
- using cmake to build on windows 7 x64 http://hdf-forum.184993.n3.nabble.com/error-LNK2019-unresolved-external-symbol-main-referenced-in-function-tmainCRTStartup-td3138042.html

Working test: - deleted everything in main.cpp except test code and excluded all source files except main.cpp; as expected it worked, so a small step in the right direction. The problem must be with one of the header files.
Last edited on
I think this is why people say learn the language THEN go deal with an IDE if you so desire.


I second that. Sounds like you need a plain text editor and a command-line compiler.
can you elaborate on that - maybe a link to something with pictures or a more descriptive explanation
Are you on windows? Do you have notepad? Do you have a command prompt? You're almost there then.
yes, I get what you are saying - so I have a fork in the road. I can take the red pill and follow your suggestion to ditch VS, eclipse, and all these other compilers, and learn (hopefully in a day or less) to use a command-line compiler. Or, I can take the blue pill, strike what you said from the record and forget you ever mentioned that - then start a new help thread and hope somebody else helps me figure out my IDE or find where my code is going south.
No reason you can't do both. Can't hurt to learn how to do everything from the command line. Granted, if you do this professionally, I'm sure most of what you do, you'll have access to all sorts of tools. But you could wind up in a situation where you don't have access to anything grapical (ie *nix systems)
any idea why VS2008 is giving error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
That usually happens when there is no main function.
Granted, if you do this professionally, I'm sure most of what you do, you'll have access to all sorts of tools.


I am technically a professional, and I do have access to all sorts of tools, and I still write all my code in EMACS and compile it with hand-crafted makefiles.

I should say that everything I write has to work on *nix AND Win32 (and I develop it on both), so there is a large element of maintaining portability of both code and coding environment - emacs and makefiles are pretty much identical on the two systems.
I do not have that constraint. right now this is supporting an experiment and the program only needs to run on my machine - for all it matters it can stay in VS2008. If this works and everybody likes it, then somebody else will rewrite it for broader use.

main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
int main() 

{
int t = 0;

while (t < 1000) {
cout << " welcome..." << endl;
t++;
}

return 0;

}
It sounds like you may need to change the subsystem to console. I'm on my phone right now and can't check but it its somewhere in the project properties.
yes, I set that up during setup and double checked in the properties - no rush, I will be working on this for the next couple weeks until solved or I hire someone to coach me through
SOLVED: the LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup solution was found here http://stackoverflow.com/questions/11247699/lnk2019-unresolved-external-symbol-main-referenced-in-function-tmaincrtstar
Last edited on
Topic archived. No new replies allowed.
Pages: 12