Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Architecture of i386 input file is incompatible with i386:x86-64

Tags:

linux

ld

i386

I'm trying to create a simple kernel using Ubuntu. In the terminal I typed

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
like image 962
MEv2.0 Avatar asked Oct 05 '13 17:10

MEv2.0


5 Answers

If want compile the file as 32 bits, you can use:

ld -m elf_i386 -s -o file file.o
like image 100
Leandro Andrade Avatar answered Oct 22 '22 06:10

Leandro Andrade


Use 64 bits instead of 32 for your loader and compile it with the following command:

nasm -f elf64 loader.asm -o loader.o

This should solve your error

like image 36
Drill Avatar answered Oct 22 '22 05:10

Drill


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

like image 6
4aRk Kn1gh7 Avatar answered Oct 22 '22 04:10

4aRk Kn1gh7


I also faced the same problem, i figured out that i am 32 bit registers(eax,ecx,edx,ebx,esp,ebp,esi,edi) insist of 64 bit registers (rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi), in my 64 bit computer. Then use these command to compile my program-

nasm -felf64 hello.asm
ld hello.o
./a.out
like image 1
Shanu Verma Avatar answered Oct 22 '22 05:10

Shanu Verma


On Windows, I faced following issue

ld: i386 architecture of input file `file.o' is incompatible with i386:x86-64 output

ld -m i386pe -s -o file.exe file.o , worked for me

like image 1
Rajeshwar_ Avatar answered Oct 22 '22 04:10

Rajeshwar_