Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to compile assembly: /usr/bin/ld: i386 architecture of input file `array1.o' is incompatible with i386:x86-64 output [duplicate]

I am using Kali linux 64 bit and I am trying to execute the following programs from Dr. Paul carter's website. The gcc command is giving errors. What should I use in the gcc command?

nasm -f elf32 array1.asm
root@kali:assembly# gcc -o array1 array1.o array1c.c
array1c.c:9:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
array1c.c:10:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/usr/bin/ld: i386 architecture of input file `array1.o' is    incompatible    with i386:x86-64 output
collect2: error: ld returned 1 exit status
like image 723
beegee Assem Avatar asked Jul 12 '15 16:07

beegee Assem


2 Answers

You are attempting to link a 32 bit object file i386 to a 64 bit executable (i386:x86-64). Add -m32 to the gcc compilation line to create a 32 bit executable.

like image 145
cadaniluk Avatar answered Nov 03 '22 16:11

cadaniluk


nasm -f elf64 array1.asm

then

ld -s -o array1 array1.o
like image 25
Chris M Brueck Avatar answered Nov 03 '22 14:11

Chris M Brueck