Discussion:
error LNK2019: unresolved external symbol _main referenced in ___t
(too old to reply)
Hongwei
2009-06-02 19:36:01 UTC
Permalink
I got the following link error after I ported my VS 2003 project to VS 2008:

"error LNK2019: unresolved external symbol _main referenced in function
___tmainCRTStartup LIBCMT.lib"

Most of posts in the internet say it can be fixed to change the subsystem to
Windows, not console (Properties > Configuration > Linker > System >
Subsystem.

But it doesn't work for me. It is Windows (/SUBSYSTEM:WINDOWS) in the
settings. The same settings works with VS 2003 C++.

Thanks in advance for suggestions!

HJ
Victor Bazarov
2009-06-02 20:50:13 UTC
Permalink
Post by Hongwei
"error LNK2019: unresolved external symbol _main referenced in function
___tmainCRTStartup LIBCMT.lib"
Most of posts in the internet say it can be fixed to change the subsystem to
Windows, not console (Properties > Configuration > Linker > System >
Subsystem.
But it doesn't work for me. It is Windows (/SUBSYSTEM:WINDOWS) in the
settings. The same settings works with VS 2003 C++.
Check the libraries. Sometimes you have some carry-over of old
libraries that don't really have to be there...

Another way is to recreate your projects from the source files instead
of "porting" them. IOW, use default settings and then just populate the
project. If you need to tweak the settings, do that as a separate step.
"Porting" does not always work, especially if you fiddled with the
settings before for some custom result...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Ben Voigt [C++ MVP]
2009-06-14 15:20:32 UTC
Permalink
Post by Hongwei
"error LNK2019: unresolved external symbol _main referenced in function
___tmainCRTStartup LIBCMT.lib"
Most of posts in the internet say it can be fixed to change the subsystem to
Windows, not console (Properties > Configuration > Linker > System >
Subsystem.
But it doesn't work for me. It is Windows (/SUBSYSTEM:WINDOWS) in the
settings. The same settings works with VS 2003 C++.
Thanks in advance for suggestions!
What is the name of your startup function, main or WinMain or wmain or
_tmain or ...?

Between VS 2003 and VS 2005 the default was changed to UNICODE, so your file
might be defining wmain now, leaving main undefined.
Post by Hongwei
HJ
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4153 (20090613) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4153 (20090613) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Continue reading on narkive:
Search results for 'error LNK2019: unresolved external symbol _main referenced in ___t' (Questions and Answers)
3
replies
LNK 2019 : Unresolved Externals Error?
started 2011-02-25 22:33:16 UTC
programming & design
Loading...