I'm attempting to make 3 separate programs mem_1.exe, mem_2.exe and mem_3.exe. I need to make them 32 bit when I compile them and the error message does not seem to be reflecting what I am writing. Below is my makefile.
mem_1: memlayout.o mem_1.o
gcc -o mem_1 memlayout.c mem_1.c -ldl -m32
mem_2: memlayout.o mem_2.o
gcc -o mem_2 memlayout.c mem_2.c -m32 -ldl
mem_3: memlayout.o mem_3.o
gcc -o mem_3 memlayout.c mem_3.c -m32 -ldl
mem_1.o: mem_1.c
gcc -c -o mem_1 mem_1.c -m32
mem_2.o: mem_2.c
gcc -c -o mem_2 mem_2.c -m32
mem_3.o: mem_3.c
gcc -c -o mem_3 mem_3.c -m32
memlayout.o: memlayout.c
gcc -c -o memlayout memlayout.c -m32
clean:
rm -f mem_1.o mem_2.o mem_3.o memlayout.o *~
Everytime I attempt to run this makefile I get this error message
cc -c -o memlayout.o memlayout.c
cc -c -o mem_1.o mem_1.c
gcc -o mem_1.exe mem_1.o memlayout.o -m32 -ldl
/usr/bin/ld: i386:x86-64 architecture of input file `mem_1.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `memlayout.o' is incompatible with i386 output
Which doesn't seem to make sense since I am using the -m32 flag to make it a 32 bit. Can anyone explain what I'm doing wrong?
question from:https://stackoverflow.com/questions/66057566/how-can-i-compile-a-32-bit-program-using-a-makefile