i am programming in Microsoft Visual c++ 6.0 and I have two linking
errors that I do not know what they mean. Can someone please help.

Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Programming Project 1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Dani AI

Generated

Short practical diagnosis: the LNK2001 for _WinMain@16 means the linker was configured for the Windows (GUI) subsystem but no matching WinMain entry point was found. The name _WinMain@16 is MSVC's decorated form for a __stdcall WinMain (the @16 shows 16 bytes of parameters — four 4-byte args). In other words, the project expects a Win32 GUI entry but the build supplies a different entry (for example a plain main).

Two safe fixes (pick the one that matches the intended program type):

  • Keep a portable console program (use main): convert the project to a console subsystem or recreate it as a console project. In Visual C++ 6.0 go to Project -> Settings -> Link and add /SUBSYSTEM:CONSOLE to Project Options, then do a full Clean + Rebuild. From the command line a quick override is:
cl program.cpp /link /SUBSYSTEM:CONSOLE
  • Make a native Win32 GUI program (use WinMain or wWinMain): implement the proper WinMain entry. This is the route suggested; it is correct for GUI apps but ties the code to Win32.

Quick troubleshooting checklist: confirm which entry point the source implements (main, WinMain, or wWinMain); check Project->Settings->Link for an accidental /SUBSYSTEM:WINDOWS; ensure all object files/libraries were compiled for the same subsystem; clean and rebuild after changes. A common compromise is a tiny WinMain wrapper that forwards to a portable main so logic remains portable while satisfying the linker.

As noted, the core issue is a project-type mismatch — choose the fix that matches whether the program is intended as a console tool or a Windows GUI application.

Recommended Answers

All 4 Replies

It means you're using the wrong project type. You created a Win32 application (which requires WinMain instead of main) and then treated it as if it were a console application (by using main instead of WinMain).

just replace your int main(void) function with :

int WINAPI WinMain(

    HINSTANCE hInstance,	
    HINSTANCE hPrevInstance,	
    LPSTR lpCmdLine,	
    int nCmdShow 	
   )

just replace your int main(void) function with :

int WINAPI WinMain(

    HINSTANCE hInstance,	
    HINSTANCE hPrevInstance,	
    LPSTR lpCmdLine,	
    int nCmdShow 	
   )

Brilliant! Destroy portability because you're too lazy to delete the project and try again. Since it's not obvious whether the OP wants portable C++ or Win32 C++, a better suggestion would be to create a new project that doesn't expect platform specific code to compile.

I love you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.