简体   繁体   中英

visual studio express 2012 simple c program fatal error LNK1561: entry point must be defined

While compiling and linking the following simple test.c using: cl.exe test.c in windows 7 console:

#include "stdio.h"
#include "stdlib.h"

int main(int argc, char* args[]){
    int i;
    i=0;
    printf("i=%d",i);
    return 0;
}

I got LINK : fatal error LNK1561: entry point must be defined. It compiles without problem, but failed in linking. Also if I change the filename to test.cpp then it works fine. Any idea?

I copied your code and compiled it with cl.exe test.c and it worked fine. I think you have a configuration problem.

First off, are you using the Visual Studio command line environment? Ensure that by typing on a command line:

vsvars32

Then try using:

cl.exe test.c kernel32.lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM