c - 如何解释 make 命令生成的输出?

标签 c bash makefile ubuntu-12.04

运行 make 命令时,我得到以下输出,

g++ -DUNIX -Wall -g -I../include -I. main.o hfpage.o hfp_driver.o                      test_driver.o db.o new_error.o page.o system_defs.o buf.o -o hfpage 

/usr/bin/ld: Warning: size of symbol `error_string_table::error_string_table(Status, char const**)' changed   from 18 in db.o to 34 in buf.o
/usr/bin/ld: i386:x86-64 architecture of input file `buf.o' is  incompatible with i386 output
collect2: ld returned 1 exit status
make: *** [hfpage] Error 1

此文件生成 hfpage.o,当我尝试使用 ./hfpage.o 运行时,我收到错误消息 bash: ./hfpage.o: 无法执行二进制文件.

我的系统有问题吗?

最佳答案

好吧,首先,错误消息显示 buf.o 是为另一种体系结构编译的,可能是 64 位机器上的 32 位体系结构。

无法运行 ./hprof.o 的原因是 hprof.o 是二进制对象,而不是可执行文件。如果此编译已完成,由于没有 -o 标志,可执行文件将被命名为 a.out,由于历史原因,它是 UNIX 可执行文件的默认名称。

您的问题可能出现在 make 文件的较早步骤中。基本上,你应该有几行,例如

main.o: 
   g++ -DUNIX -Wall -g -I../include -I. -c main.C

然后是最后一行

main:
   g++ -DUNIX -Wall -g -o main main.o hfpage.o hfp_driver.o

架构消息建议您使用不同的编译器或编译器标志编译 buf.o

关于c - 如何解释 make 命令生成的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12613598/

相关文章:

c - 为什么我的 for 循环适用于 "&&"而不适用于 ","

c - 在c中用双变量打印字符

linux - 在 bash 中为单个脚本重命名可执行文件

makefile - 如何将makefile目标中的 '$*'值大写?

bash - 管道在 makefile 中不起作用

makefile - 项目的多目录 makefile

c - 如何使用 C 套接字 ping

c - 将指针与数组一起使用时遇到问题

linux - 使用 make 从头开始​​为 Linux 编译 Glibc-2.11.1 时出错

bash - 蒙戈 : drop collection using the terminal