Reputation: 1513
Visual Studio 2010, during a C compile, complains about
MSVCRTD.lib(crtexe.obj) : error LNK2019 and fatal error LNK1120
I've read that you must change the configurations of the project under properties-->linker-->subsystem--> Subsystem/Console(/SUBSYSTEM:CONSOLE) but that's not my case.
The code should print a line of text
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("As soon as installed, VS2010 can't compile. Or maybe I'm doing something wrong.");
return 0;
}
Include files are correctly installed in the include directory.
Edit: the complete error messages are:
MSVCRTD.lib(crtexe.obj) : unresolved external symbol _main referenced in function ___tmainCRTStartup
and
fatal error LNK1120: 1 unresolved external link
Upvotes: 0
Views: 770
Reputation: 11944
As you have stated in the question in many cases the issue is because people select wrong project type in the project setup wizard in Visual Studio. Using "Console application" will make the linker look for _main
while "Windows application" will make the linker look for _WinMain
(see WinMain on MSDN). However, if the subsystem is right, another simple error that can lead to linking failures is (unknowingly) not defining _main
. If for some reason _main
is in your source but is not actually generated (possibilities include the source not being included in the build for some reason, the function being not generated because of some macro definitions that guard it, etc.) you will still get the errors you see.
Upvotes: 1