============================================================ title : gcc-32-bit-compile-on-64-bit-rhel.txt author: Neil Rieck (Waterloo, Ontario, Canada) edit : 2022-07-04 legend: <ur> (user response) <sr> (system response) ============================================================ (can we run both 32 + 64 bit apps on this platform?)
<ur> lscpu <sr> Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit (YES) Byte Order: Little Endian ...snip... $ ------------------------------------------------------------ (64-bit native build)
<ur> gcc hello_linux_world.c -o hello_linux_world64 <sr> $ ------------------------------------------------------------ (32-bit build which fails)
<ur> gcc -m32 hello_linux_world.c -o hello_linux_world32 In file included from /usr/include/features.h:399:0, from /usr/include/stdio.h:27, from hello_linux_world.c:1: /usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory # include <gnu/stubs-32.h> ^ compilation terminated. ------------------------------------------------------------ (install 32-bit development libs)
<ur> sudo yum install glibc-devel.i686 \
libgcc.i686 \
libstdc++-devel.i686 \
ncurses-devel.i686 <sr> ...verbiage...
$ ------------------------------------------------------------ (32-bit build which now works)
<ur> gcc -m32 hello_linux_world.c -o hello_linux_world32 <sr> $ ------------------------------------------------------------ (testing)
<sr> $ <ur> gcc hello_linux_world.c -o hello_linux_world64 # native <sr> $ <ur> gcc -m32 hello_linux_world.c -o hello_linux_world32 # optional <sr> $ <ur> ls -la hello* <sr> -rwxr-xr-x. 1 neil admgrp 7264 Aug 6 10:32 hello_linux_world32 -rwxr-xr-x. 1 neil admgrp 8424 Aug 6 10:32 hello_linux_world64 -rw-r--r--. 1 neil admgrp 1258 Aug 6 10:32 hello_linux_world.c $ <ur> ./hello_linux_world32 one two <sr> Hello World from program: ./hello_linux_world32 cli argc 3 cli arg 0 ./hello_linux_world32 cli arg 1 one cli arg 2 two adios $ <ur> ./hello_linux_world64 three four <sr> Hello World from program: ./hello_linux_world64 cli argc 3 cli arg 0 ./hello_linux_world64 cli arg 1 three cli arg 2 four adios $
# sudo yum grouplist # view choices # sudo yum -y groupinstall 'Development Tools' # installs x86_64 support # sudo yum -y groupinstall 'Compatibility Libraries' # adds full i686 support
Back to Linux Demo Index
Back to Real-world
Linux Problems + Solutions
Back to Home
Neil Rieck
Waterloo, Ontario, Canada.