# LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in

This topic is 3999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi, LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup i am facing the errors but i want to link statically . so i don't want to ignore libc libraries and i have tried with all the subsystems(console and windows) but nothing works . There is no minimum use of ATL also. There is a _DllMainCRTStartup function which is set as the entry and one more thing to note is the file is a .c file . i am quoting this because when i rename the file to .cpp and remove the entry point .its builds without linker errors. But unfortunately i am not allowed to do this.The configuration is Win32/Release. Hope these information is enough. Can any one help at the earliest

##### Share on other sites
___tmainCRTStartup is a EXE file entry point.
_DllMainCRTStartup is a DLL file entry point.

Are you building a DLL or EXE?

##### Share on other sites
i am trying to buid a DLL

##### Share on other sites
When you created the project, did you explicitly create a DLL, or did you just create a Win32 application project?

And what IDE are you using?

##### Share on other sites
S i expl defined as dll . i am buiding in visual studio 2005.

actually while creating i created as win32 application and in that i have selected dll option.

##### Share on other sites
Can you create a minimal project that shows this behaviour? I just created a new DLL project with a .c file with the following contents, and the entry point set in the linker settings, and it links fine:
void __stdcall _DllMainCRTStartup(void* hinstDLL, unsigned long fdwReason, void* lpReserved){}

##### Share on other sites
IT WORKS BUT
try including this code segment with that _DllMainCRTStartup

int test()
{
int *i;
i= (int*) malloc(4);
return 0;
}

it now fails with the same error..

now can you get some idea ..

##### Share on other sites
Quote:
 Original post by gshankaranIT WORKS BUT try including this code segment with that _DllMainCRTStartupint test(){int *i;i= (int*) malloc(4);return 0;}it now fails with the same error..now can you get some idea ..

Of course it will fail. You cannot call a CRT function (malloc) in the function that is supposed to initialize the CRT...

Why are you overloading _DllMainCRTStartup anyway ? You do realize that there is a whole ton of stuff you have to manually include in that function for it to work properly (init the CRT, call static ctors, etc) ? Just use DllMain instead.

##### Share on other sites
is there any other way to make it run with the use of _DllMainCRTStartup..

##### Share on other sites
Quote:
 Original post by gshankaranis there any other way to make it run with the use of _DllMainCRTStartup..if so can you please help me..what are the changes i should do.

As I said above, use DllMain. There are very few reasons to use _DllMainCRTStartup instead (eg. if you wrote your own replacement CRT, or if you are targeting a system without CRT), and none of these apply to you.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 23
• 13
• 10
• 9
• ### Forum Statistics

• Total Topics
634470
• Total Posts
3017686
×