Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Compiling .asm and .c files gives "i386 incompatibility" problem when trying to link objective files [duplicate]

$
0
0

I'm trying to accomplish an exercise, which goal is to print a message without C standard library, using own nasm code instead. I've successfully compiled two .asm and one .c file with following commands

nasm -f elf start.asm
nasm -f elf calls.asm
gcc -Wall -c greet.c

all good, but when I try to link all of the objective files with

ld start.o calls.o greet.o -o greet

it says

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

I've tried using following command instead

ld -m elf_i386 start.o calls.o greet.o -o greet

but no good

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

Please help. I'm using Ubuntu 19.10 (Virtual Machine), NASM ver. 2.14.02, GCC ver. 9.2.1 20191008.


Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>