[英]Linker error: undefined reference to `main'
#include <cs50.h>
#include <stdio.h>
bool maths (int a, int b, int c)
{
int first = a + b;
int second = b + c;
int third = c + a;
if (first <= c)
{
return false;
}
else if (second <= a)
{
return false;
}
else if (third <= b)
{
return false;
}
else
{
return true;
}
}
I get the error message undefined reference to `main'
when I try to compile.当我尝试编译时,我收到错误消息
undefined reference to `main'
。 I have tried to look up this error message, but the stuff I find is over my head.我试图查找此错误消息,但我发现的东西超出了我的想象。 Can anyone explain to a novice like me what I have done wrong?
谁能向像我这样的新手解释我做错了什么?
$ clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow triangle.c -lcrypt -lcs50 -lm -o triangle
/usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [<builtin>: triangle] Error 1
It seems that a main
function is missing in your program.您的程序中似乎缺少
main
的 function 。
#include <cs50.h>
#include <stdio.h>
bool maths (int a, int b, int c)
{
int first = a + b;
int second = b + c;
int third = c + a;
if (first <= c)
{
return false;
}
else if (second <= a)
{
return false;
}
else if (third <= b)
{
return false;
}
else
{
return true;
}
}
int main ()
{
maths(1,2,3);
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.