1
votes

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?

1

1 Answers

0
votes

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