c++ - LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup -


i have following error lnk2019: unresolved external symbol _main referenced in function ___tmaincrtstartup,

there lot of threads relating error none of solutions worked me. and, none explained why error here.

i tried:

have not tried , suspect these not work:

why getting error , solution?

what project type? if it's "win32 project", entry point should (w)winmain. if it's "win32 console project", should (w)main. name _tmain #defined either main or wmain depending on whether unicode defined or not.

if it's dll, dllmain.

the project type can seen under project properties, linker, system, subsystem. either "console" or "windows".

note entry point name varies depending on whether unicode defined or not. in vs2008, it's defined default.

the proper prototype main either

int _tmain(int argc, _tchar* argv[]) 

or

int _tmain() 

make sure it's 1 of those.

edit:

if you're getting error on _tchar, place an

#include <tchar.h> 

if think issue 1 of headers, go properties of file main(), , under preprocessor, enable generating of preprocessed file. compile. you'll file same name .i extension. open it, , see if unsavory happened main() function. there can rogue #defines in theory...

edit2:

with unicode defined (which default), linker expects entry point wmain(), not main(). _tmain has advantage of being unicode-agnostic - translates either main or wmain.

some time ago, there reason maintain both ansi build , unicode build. unicode support sorely incomplete in windows 95/98/me. primary apis ansi, , unicode versions existed here , there, not pervasively. also, vs debugger had trouble displaying unicode strings. in nt kernel oses (that's windows 2000/xp/vista/7/8/10), unicode support primary, , ansi functions added on top. ever since vs2005, default upon project creation unicode. means - wmain. not keep same entry point name because parameter types different. _tchar #defined either char or wchar_t. _tmain either main(int argc, char **argv) or wmain(int argc, wchar_t **argv).

the reason getting error @ _tmain @ point because did not change type of argv _tchar**.

if you're not planning ever support ansi (probably not), can reformulate entry point as

int wmain(int argc, wchar_t *argv[]) 

and remove tchar.h include line.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -