eclipse 对“WinMain@16”collect2.exe 的未定义引用:错误:ld 返回 1 个退出状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16946307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status
提问by annunarcist
I am using eclipse CDT to test the Intel instructions and below is my program:
我正在使用 eclipse CDT 来测试英特尔指令,下面是我的程序:
#define cpuid(func,ax,bx,cx,dx)\
__asm__ __volatile__ ("cpuid":\
"=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func));
int Check_CPU_support_AES()
{
unsigned int a,b,c,d;
cpuid(1, a,b,c,d);
return (c & 0x2000000);
}
When I compile the above code, I get linkage error as:
当我编译上面的代码时,我得到链接错误:
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o "src\Intel.o" "..\src\Intel.c"
gcc -o Intel.exe "src\Intel.o"
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Please help me regarding the issue.
请帮助我解决这个问题。
采纳答案by Carl Norum
Your program isn't complete. You need to implement the OS-expected entry point. In your case, that looks like it's called WinMain
.
你的程序不完整。您需要实现操作系统预期的入口点。在您的情况下,它看起来像是称为WinMain
.
回答by Chandra Shekhar
Yes, Main () function is missing and the compiler is not able to find an entry point for executing the program.
是的,缺少 Main() 函数,编译器无法找到执行程序的入口点。
One more reason is even if you have written the main function but if you didnot save the .cpp file and try to compile it will give the same error.So make sure you have successfully saved the .cpp file and then compile and run your code.
另一个原因是,即使您已经编写了 main 函数,但是如果您没有保存 .cpp 文件并尝试编译它也会出现相同的错误。因此请确保您已成功保存 .cpp 文件,然后编译并运行您的代码.
Hope this will help since I have faced similar issue and I spent around hours to figure it out , Thanks
希望这会有所帮助,因为我遇到了类似的问题,我花了大约几个小时来弄清楚,谢谢