【问题标题】:visual studio express 2012 simple c program fatal error LNK1561: entry point must be definedvisual studio express 2012 simple c program fatal error LNK1561: entry point must be defined
【发布时间】:2012-11-30 04:55:56
【问题描述】:

在编译和链接以下简单的 test.c 时,在 windows 7 控制台中使用:cl.exe test.c:

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

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

我得到了 LINK:致命错误 LNK1561:必须定义入口点。它编译没有问题,但链接失败。此外,如果我将文件名更改为 test.cpp,那么它工作正常。有什么想法吗?

【问题讨论】:

    标签: c visual-studio-2012


    【解决方案1】:

    我复制了您的代码并使用cl.exe test.c 对其进行了编译,并且运行良好。我认为您的配置有问题。

    首先,您使用的是 Visual Studio 命令行环境吗?确保通过在命令行上键入:

    vsvars32
    

    然后尝试使用:

    cl.exe test.c kernel32.lib
    

    【讨论】:

    • 感谢您的回复。我试过你的建议,但没有奏效。我正在使用 VS 2012 Express。同样,CPP 文件没有问题,只是 C 文件无法链接。
    猜你喜欢
    • 2022-12-27
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多