【发布时间】:2017-01-30 12:39:57
【问题描述】:
我尝试在我的 c 源代码上使用 make 并创建了可执行文件。但可执行文件没有完成预期的任务。即使当我尝试单独编译.c文件时make文件编译并生成了可执行文件,它也给出了许多未定义的引用问题 错误是
/tmp/cc4tx0BG.o: In function `main':
cubist.c:(.text+0xdc): undefined reference to `Of'
cubist.c:(.text+0xe7): undefined reference to `Of'
cubist.c:(.text+0xfa): undefined reference to `Of'
cubist.c:(.text+0x10f): undefined reference to `KRInit'
cubist.c:(.text+0x114): undefined reference to `ExecTime'
cubist.c:(.text+0x127): undefined reference to `PrintHeader'
cubist.c:(.text+0x139): undefined reference to `Of'
[...]
cubist.c:(.text+0xb79): undefined reference to `MaxAtt'
cubist.c:(.text+0xb83): undefined reference to `InitialiseEnvData'
cubist.c:(.text+0xb8a): undefined reference to `XVAL'
cubist.c:(.text+0xb93): undefined reference to `CrossVal'
cubist.c:(.text+0xb9a): undefined reference to `SingleCttee'
cubist.c:(.text+0xb9f): undefined reference to `ExecTime'
cubist.c:(.text+0xbab): undefined reference to `Of'
collect2: error: ld returned 1 exit status
拜托,任何人都可以告诉如何在 Linux 中使用 make 和构建可执行文件。
【问题讨论】:
-
减少输出,从前 10 行开始就可以理解了。
-
我认为这是一个链接错误。你是如何编译你的源代码的?
-
我使用 gcc 编译器来获取名为 cubist 的可执行文件。 gcc -o cubist cubist.c
-
@melaku 您使用的工具链是标准的还是定制的?您能否也发布您的来源 cubist.c - 我们可能会更好地帮助您。
-
是标准工具链。 Cubist 的 GPL 版本 c 源代码可在 (rulequest.com/download.html) 获得。你也可以看到cubist.c
标签: c linux compiler-errors executable gnu-make