作者SNSDpk5566 (5566 超强)
看板C_and_CPP
标题[问题] linux 中 ld 指令问题
时间Wed Dec 9 19:03:06 2015
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
linux
请问一下 我在ubuntu 14版 64位元下 想要用ld 连结两个 .o档案
foo.o是C语言 bar.o是组语编出来的 我想要连结两个档案
输入 ld -s -o foobar foo.o bar.o
发生下面的问题
ld: i386 architecture of input file `foo.o' is
incompatible with i386:x86-64 output
爬网路改起来是要改用 elf_i386 於是改为
ld -m elf_i386 -s -o foobar foo.o bar.o
一样还是有相同的问题
但是单独使用
ld -m elf_i386 -o hello hello.o 这样可以
想问一下两个档案连结要怎麽使用ld指令
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 218.161.13.208
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1449658989.A.0AE.html
1F:→ MinamiChiaki: 感觉一个 32 一个 64 位元? 12/09 20:56
2F:推 christianSK: readelf看一下两个.o file是不是同一个架构? 12/10 09:00