【问题标题】:gcc on i386 architecturei386 架构上的 gcc
【发布时间】:2012-03-11 22:03:54
【问题描述】:

我正在尝试将一些 .o 文件链接到:

gcc -m32 send.o lib.o -o send

我得到:

/usr/bin/ld: i386:x86-64 architecture of input file `send.o' is incompatible with i386 output
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status

我已经安装了 libc6-i386 gcc-multilib ia32-lib

问题可能出在哪里?

【问题讨论】:

    标签: gcc makefile i386


    【解决方案1】:

    你没有编译。您正在链接已编译的目标文件。看来 send.o 被编译为 x86_64 对象(没有 -m32)。您不能从 32 位目标文件链接 64 位可执行文件。

    确保所有目标文件都以 32 位模式编译。

    【讨论】:

    • 对不起,我只是链接它们。我也试过没有 -m32,它不起作用,我确定文件是在 x86 架构上编译的。
    • 那么lib.o就是ELF32,不兼容64位输出。
    • 在没有 -m32 的情况下链接时会收到什么错误消息? 'file send.o lib.o' 的输出是什么?
    猜你喜欢
    • 1970-01-01
    • 2019-01-18
    • 1970-01-01
    • 2013-01-17
    • 2016-04-16
    • 1970-01-01
    • 2012-08-30
    • 2012-12-29
    • 2011-08-14
    相关资源
    最近更新 更多