Linker error: undefined reference to `main'
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;
}
}
我在尝试编译时收到错误消息 undefined reference to `main'
。我试图查找此错误消息,但我发现的东西超出了我的理解范围。谁能给像我这样的新手解释一下我哪里做错了?
$ 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
您的程序中似乎缺少 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;
}
}
int main ()
{
maths(1,2,3);
return 0;
}
#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;
}
}
我在尝试编译时收到错误消息 undefined reference to `main'
。我试图查找此错误消息,但我发现的东西超出了我的理解范围。谁能给像我这样的新手解释一下我哪里做错了?
$ 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
您的程序中似乎缺少 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;
}
}
int main ()
{
maths(1,2,3);
return 0;
}