Jump to content
  • Advertisement
Sign in to follow this  
gshankaran

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
___tmainCRTStartup is a EXE file entry point.
_DllMainCRTStartup is a DLL file entry point.

Are you building a DLL or EXE?

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by gshankaran
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 ..

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 this post


Link to post
Share on other sites
is 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.

Share this post


Link to post
Share on other sites
Quote:
Original post by gshankaran
is 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!