0

我正在尝试编写一个 shell 命令来查找和编译所有 C 程序

  find . -type f -name '*.c' -exec sh -c 'gcc {} -o $(dirname {})/$(basename {} .c)' \;

就是我现在所拥有的,它实际上编译了所有 C 文件,但它也返回了这些错误。

/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

我完全被困住了,任何帮助都将不胜感激。

4

1 回答 1

0

您可能没有为您的 C 文件/文件定义 main 。当您尝试为每个 C 文件创建单独的可执行文件时,请检查您的个人包含内容。你可能想显示你编译文件的#include。

于 2013-05-13T08:57:08.877 回答