【发布时间】:2020-04-27 22:27:15
【问题描述】:
我正在做一个项目,但由于某种原因,我的代码无法编译并打印错误消息。
''' /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crt1.o: In function
`_start': (.text+0x20): undefined reference to `main' clang-7: error: linker command failed
with exit code 1 (use -v to see invocation) <builtin>: recipe for target 'helpers' failed
make: *** [helpers] Error 1 '''
强调
undefined reference to 'main'.
我没有发现任何问题,这是我的代码,我将不胜感激。
我的代码
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
// over height
for (int h = 0; h < height; h++)
{
// over width
for ( int w = 0; w < width; w++)
{
int sepiaRed = .393 * image[h][w].rgbtRed + .769 * image[h][w].rgbtGreen + .189 * image[h][w].rgbtBlue;
int sepiaGreen = .349 * image[h][w].rgbtRed + .686 * image[h][w].rgbtGreen + .168 * image[h][w].rgbtBlue;
int sepiaBlue = .272 * image[h][w].rgbtRed + .534 * image[h][w].rgbtGreen + .131 * image[h][w].rgbtBlue;
// space
if (sepiaRed > 255 || sepiaGreen > 255 || sepiaBlue > 255)
{
sepiaRed = 255;
sepiaGreen = 255;
sepiaBlue = 255;
}
image[h][w].rgbtRed = (sepiaRed);
image[h][w].rgbtBlue = (sepiaBlue);
image[h][w].rgbtGreen = (sepiaGreen);
}
}
return;
}
【问题讨论】:
-
如果你的程序是一个独立的可执行文件,它需要一个
main例程,而你的代码没有。如果您的代码要与提供main例程的其他代码一起使用,您必须链接到该代码。为了帮助您,我们必须知道您想要实现什么以及如何构建您的程序。 -
(不相关的旁注:您应该单独检查组件的范围溢出。现在的方式是,如果三个组件中的任何一个超过最大值,您的代码将显示一个白色像素。)跨度>
标签: c