469,934 Members | 1,642 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

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


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;

}

}
Nov 17 '05 #1
8 13485
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()

--
Jeff Partch [VC++ MVP]
Nov 17 '05 #2
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.
--------------------
Nov 17 '05 #3
Gary and Jeff,
I found a problem in my config of vs.net and things are up and running
again.
Thanks!
- Bruce

"Gary Chang" <v-******@online.microsoft.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
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. --------------------

Nov 17 '05 #4

Bruce Schechter wrote:
[b]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
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message754971.htm

Nov 17 '05 #5

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
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message754971.htm

Nov 17 '05 #6
"stiiv86" <st************@mail.mcse.ms> wrote in message
news:st************@mail.mcse.ms...
--------------------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
Nov 17 '05 #7

thank you for your help,
i'm quite new to C++
now it works :
-
stiiv8
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message754971.htm

Nov 17 '05 #8

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
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message754971.htm

Nov 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bcoder77 | last post: by
4 posts views Thread by =?Utf-8?B?amM=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.