centos 7에서 gcc로 32bit compile
환경
OS: CentOS Linux release 7.4.1708 (Core)
gcc:
gcc-4.8.5-16.el7_4.1.x86_64
libgcc-4.8.5-16.el7_4.1.x86_64
libgcc-4.8.5-16.el7_4.1.i686
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
32bit 컴파일를 하려 했건만.. 위 환경에서는 gcc가 -m[32|64] 옵션이 없을 경우 기본으로 64bit 컴파일이다..;; 언제부터 바뀐거지.. 원래 이랬었나;;?
object 파일로 확인.. 제길
[test@test-linux server]$ file test.o
test.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
gcc -m32 ... 로 컴파일하면 아래와 같이 에러가 발생
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: 그런 파일이나 디렉터리가 없습니다
glibc-devel.i686 설치로 해결..
[root@test-linux ~]# yum install glibc-devel.i686 -y
블로그 고마워요 하하