LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main

  • Thread starter Thread starter Bruce Schechter
  • Start date Start date
B

Bruce Schechter

I am quite experienced with vs.net 2003 and c# but fairly new to c++. I
have a test app in c++ that I need to compile for a c#/c++ interop
evaluation I'm doing.



But first, I simply need to compile some straightforward, non-managed,
console based c++ code. I created a win32 console c++ project. Then I
added several "existing" c++ .cpp and .h files. When I try to compile, I
get this error...



LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup

Debug/player-cpp-only.exe : fatal error LNK1120: 1 unresolved externals



My player-cpp-only.cpp file contains "main()". The error above leads me to
believe something is going wrong in or near the file containing main(), so I
have included the contents of that file below.



Recommendations for debugging will be greatly appreciated.



Thanks, Bruce



// player-cpp-only.cpp

#include "player.h"



namespace nsPlayer

{

int main()

{

Player player( "Test Player", false );

DiskCollection disks( "disks.dat", "Bruce's Disk Collection" );

player.attachAC(true);



return 0;

}



}
 
I suspect your namespace makes your main COMDAT something like...

?main@nsPlayer@@YAHXZ

....whereas _mainCRTStartup is looking for...

_main

....I bet if you take it out of the namespace it'll work, but if you still
have problems, you probably need to redeclare it as...

extern "C" int main()
 
Hi Bruce,

Do you have tried Jeff's suggestion?


Keep the information coming!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Gary and Jeff,
I found a problem in my config of vs.net and things are up and running
again.
Thanks!
- Bruce
 
Bruce said:
Gary and Jeff,
I found a problem in my config of vs.net and things are up an
running
again.
Thanks!
- Bruce



Hi Bruce,

I'm having similar trouble in vs.net. Do you remember what you di
to fix the problem with the coniguration? I'd appreciate any help.

- Wyat



-
Wyatt Lindse
 
hi,
im having the same problem
when i try to compile my code it will give me error
my code is:

int main()
{
int i;
i=6;
return(0);
}

and error:

--------------------Configuration: kolmas - Win3
Debug--------------------
Compiling...
kolmas.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbo
_WinMain@16
Debug/kolmas.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

kolmas.exe - 2 error(s), 0 warning(s)

can you please help me
i cant compile my code, i have this error since i installed allegr
librar


-
stiiv8
 
stiiv86 said:
--------------------Configuration: kolmas - Win32
Debug--------------------
Compiling...
kolmas.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol
_WinMain@16
Debug/kolmas.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

kolmas.exe - 2 error(s), 0 warning(s)

can you please help me
i cant compile my code, i have this error since i installed allegro
library

Windowed applications on Win32 begin at WinMain() while character mode
applications begin at main(). Apparently you have mistakenly created a
Windowed project with console application code.

Regards,
Will
 
Hi,

I am getting the same error, but with an ATL-based COM project. As fa
as I know it doesn't have a main(). So what is going on? Any help woul
be appreciated.

Royc


-
RFicklin
 
Back
Top