Linux i386 输入文件的架构与 i386:x86-64 不兼容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19200333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Architecture of i386 input file is incompatible with i386:x86-64
提问by MEv2.0
I'm trying to create a simple kernel using Ubuntu. In the terminal I typed
我正在尝试使用 Ubuntu 创建一个简单的内核。在终端我输入
ld -Ttext 0x1000 -o kernel.bin loader.o main.o Video.o
But I got the following error message in return:
但我收到以下错误消息作为回报:
ld: i386 architecture of input file `loader.o' is incompatible with i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000
回答by Drill
Use 64 bits instead of 32 for your loader and compile it with the following command:
为您的加载程序使用 64 位而不是 32 位,并使用以下命令编译它:
nasm -f elf64 loader.asm -o loader.o
This should solve your error
这应该可以解决您的错误
回答by Leandro Andrade
If want compile the file as 32 bits, you can use:
如果要将文件编译为 32 位,可以使用:
ld -m elf_i386 -s -o file file.o
回答by 4aRk Kn1gh7
When compiling/linking 32-bit apps on x86_64, setting emulation to elf_i386
provides the correct elf format. So, for example, if you compile an assembler app with nasm -f elf file.asm -o file.o
, the link command is ld -m elf_i386 -o exename file.o
Courtesy: David
在 x86_64 上编译/链接 32 位应用程序时,将仿真设置为elf_i386
提供正确的 elf 格式。因此,例如,如果您使用 编译一个汇编程序应用程序nasm -f elf file.asm -o file.o
,则链接命令是ld -m elf_i386 -o exename file.o
礼貌的:David