Programming Tips - gcc: compile a 32-bit program on a 64-bit system

Date: 2020dec20 Q. gcc: compile a 32-bit program on a 64-bit system A. This worked for me. Use -m32 flag to g++ and ld Install the needed 32-bit libraries:
dnf install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686
Here is a simple Makefile that does the trick
CC = gcc LDFLAGS = -L/usr/lib -lstdc++ -m32 CFLAGS = -g -L/usr/lib -I. -Wall -m32 CPPFLAGS = $(CFLAGS) all: myprog myprog: myprog.o $(CC) $(CFLAGS) -o $@ myprog.o $(LDFLAGS)