C++ - 对`WinMain@16 的未定义引用 [英] C++ - undefined reference to `WinMain@16
问题描述
我在网站上得到了 .h 和 .cpp 代码,我正在尝试编译它们.这是包含代码的网站:http://raphaelcruzeiro.com/blog/implementing-a-sha1-algorithm-in-c/
I got a .h and .cpp codes on a website and I am trying to compile them. This is the website that contains the codes: http://raphaelcruzeiro.com/blog/implementing-a-sha1-algorithm-in-c/
我正在创建一个新项目,选择控制台应用程序"并将 .h 和 .cpp 文件添加到项目中,但是当我尝试编译时,我总是收到此错误未定义对 WinMain@16 的引用".
I am creating a new project, selecting "console application" and adding the .h and the .cpp files to the project, but when I try to compile I always get this error "undefined reference to `WinMain@16".
我尝试过 DevC++ 和 Codeblocks,他们都遇到了同样的错误.
I tried DevC++ and Codeblocks both of them got the same error.
请问我想要有关如何编译这些文件的所有详细信息,是否可以使用#include?如果你们请一步一步做一个简单的我会很高兴.
Please I want all details on how to compile these files, is there a #include to use? If you guys please make a simple step by step I would be very glad.
在本网站 http://raphaelcruzeiro.com/blog/implementation-a-sha1-algorithm-in-c/ 你会找到 .h 和 .cpp 代码.
On this website http://raphaelcruzeiro.com/blog/implementing-a-sha1-algorithm-in-c/ you will find the .h and the .cpp codes.
提前致谢
推荐答案
所有 C++ 程序都需要某种 main()
函数,这是它们开始执行的地方.网站上的代码没有 main()
,导致编译器抱怨(这是正确的 - 程序不知道从哪里开始).
All C++ programs require some sort of main()
function, which is where they start executing. The code on the website has no main()
, causing the compiler to complain (and rightly so - the program wouldn't know where to start).
您需要在 .cpp 文件中添加如下内容:
You'll need to add something like the following to your .cpp file:
int main(int argc, char **argv) {
/* code to do SHA1 stuff */
return 0;
}
这篇关于C++ - 对`WinMain@16 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!