Hi Justin!
i am completely new to this and have to learn the language
fairly rapidly, got myself a decent book, but when i try and compile a
simple hello world program i get the error:
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol
_WinMain@16 referenced in function _WinMainCRTStartup
Debug\dont know.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Justin
Pyfrom\My Documents\Visual Studio 2005\Projects\dont know\dont
know\Debug\BuildLog.htm"
dont know - 2 error(s), 0 warning(s)
the hello world code is in a .cpp file format and the code is:
#include <iostream>
int main()
{
std::cout << "Hello
World|n";
return
(0);
}
Please change the "subsystem" in your linker settings from "Windows" to
"Console".
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
Aman JIANG
The Visual Studio Hello World main and WinMain ILLUSION
IT JUST WORKS OR DOES IT
Yes it does, just solve the ILLUSION.
If you have been writing C++ for years you will realise that Microsoft C++ compiler and linker Error Messages are 5 times worse than GNU C++. Nice programming environment and very good .NET framework ideas do not make up for the bad unintelligent terse OUT OF CONTEXT error messages. This is a case in point:
Explanation of the ILLUSION.
int main(int argc, char *argv[]) You probably need to set Project->properties->linker->system->subsystem to CONSOLE
If you have an INCOMPATIBLE NON STANDARD C++ main; breaking all the standards in the book; such as the Microsoft veriety then set the same subsystem property to WINDOWS
THE ERRORs if you SET subsystem to CONSOLE is:
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
OR THE ERROR if you SET subsystem to WINDOWS is:
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
The error means you do not have the main visible to the the linker. But you are editing the file with main or WinMain in the VS Editor, so what is wrong
Visual Studio can be used as a stand alone editor giving you the illusion that the stuff you are editing can and should be compilable. So the solution is simple you failed to add the file you are editing to the project.
Right click on solution name->Add->Existing Item->file with main
Ctl-shift-B and it compiles Hello World.
SOLVED BUT MICROSOFT NEED TO ADD AN INTELLIGENT LOOK AND SEE WHAT THE DEVELOPER HAS IN HIS EDIT SCREENs. USER CONTEXT IS VITAL FOR SMART ERROR MESSAGES - TOTALLY ABSENT IS ANY SMART ERROR MESSAGE IN THE OUTPUT FROM THE COMPILER AND LINKER.
startingVBNet
A solution if it is a UNICODE build:
Put
wWinMainCRTStartup
as entry point in the linker properties.
Shedal
i've enclosed the main.cpp into my project and i'm sure i'm using the /subsystem:console, but i still got the error:
------ Build started: Project: CEGUI, Configuration: Debug Win32 ------
Linking...
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
C:\Documents and Settings\billconan\桌面\CEGUI\Debug\CEGUI.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\billconan\桌面\CEGUI\CEGUI\Debug\BuildLog.htm"
CEGUI - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
FourT2
I found I had to set the subsystem to notset
-Al
wakeup
For these types of errors, it's easier to just start all over again, choose the right type of project from the New Project Wizard and copy your old code into there.
eg. if you're going to use .NET, make sure you choose a CLR project. If you're going to use MFC, make sure you choose an MFC project.
Erik Poirier
Hello farang,
What is CSoundManager Can we see the definition of that class and/or the source code to it
LaVinci
I am using Visual Studio 2005, which does not have a lot of documentation out yet, so I will describe how to do this.
Right click on the Project name in the "Solution Explorer" (Gag)
Select Properties
Open Linker in Configuration Properties
Subsystem will be the first item on the list. Select "Windows (/SUBSYSTEM:WINDOWS)" on the dropdown
Todd
Sirus Softs Inc.
I obtained the same error. If you change "subsystem" in your linker settings from "Windows" to "Console" then you obtain the error:
msvcrtd.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
So, it is not a solution!!!!
ertobias
Trekforcode.
The linker error is caused by your source lacking a main(). Having just one line which says #include <windows.h>, is not enough to get a program to build.
All windows C++ applications must define a function which will be designated as the entry point. By default, it is called main and looks like the function that JustinPyfrom wrote. Without this main function, your program does nothing, and VC++ will not build it. If you copy the code that JustinPyfrom wrote and put it into yours, I think you'll find that your build errors will be eliminated.
If you're completely starting out with C++ (and not just Windows programming), I'd advise against trying to learn Windows Programming simultaneously with C++. Start off programming with standard C++ (ie. command prompt apps) first of all, become an expert in that language, then move onto Windows programming.
BobConsultant2
Hello, sounds like you know what you're talking about. but can you explain this lke you were talking to a baby.
Am using VS 6.0 and am programming a game, starting with the registering and creating of a window. haven't got a clue what to do, basically have got this far
#include <windows.h>
am speed learning this subject but the code i've been experimenting with brings up that error
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/try3.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Didn't et what you said in your solution above. can you help me thanks
RESAI AHMET CUBUKCU
Im having a similiar problem, but...
In this respect, Im using VS 2005, tryin to run the compiled app ... It compiles after I convert to Console.
But when I dbl clik, It fails. But the app does require arguments, would this be a problem cause
John Needham
i am completely new to this and have to learn the language fairly rapidly, got myself a decent book, but when i try and compile a simple hello world program i get the error:
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
Debug\dont know.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Justin Pyfrom\My Documents\Visual Studio 2005\Projects\dont know\dont know\Debug\BuildLog.htm"
dont know - 2 error(s), 0 warning(s)
the hello world code is in a .cpp file format and the code is:
#include <iostream>
int main()
{
std::cout << "Hello World|n";
return (0);
}
Any help would be very much appreciated
Thanks
JustinPyfrom@hotmail.com
james_cline_
Bao Baboon
You are awesome, thanks for pointing that out. I clicked and dragged one file from one project into another, and I couldn't figure out why I was getting that error. Your solution fixed it :)
vsnk
Linking...
lib file aanroepen.obj : error LNK2019: unresolved external symbol "public: void __thiscall CSoundManager::isplaying(int)" ( isplaying@CSoundManager@@QAEXH@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" ( WndProc@@YGJPAUHWND__@@IIJ@Z)
Debug/lib file aanroepen.exe : fatal error LNK1120: 1 unresolved externals
Visual Studio Projects\lib file aanroepen\Debug\BuildLog.htm"
lib file aanroepen - 2 error(s), 0 warning(s)
This is only since I tried to add a function to my code and call that function. Can anyone guide me out here Thanks sincerely