oz123
oz123

Reputation: 28838

run a 32bit program on a 64bit gentoo linux

I am having difficulties running 32bit code on my 64bit gentoo, the program is very simple:

#include <stdio.h>

main()
{
        printf("Hello World");    
}

I compiled it with gcc -m32 -o hello32 hello.c. The output seems correct:

ozn@yeni2gen:~$ gcc -m32 -o hello32 hello.c
ozn@yeni2gen:~$ file hello32 
hello32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, not stripped

But when I try to run the file I get an error:

./hello32 
bash: ./hello32: No such file or directory

updated

ozn@yeni2gen:~$ bash --version
GNU bash, version 4.2.53(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>


ozn@yeni2gen:~$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.8.3/work/gcc-4.8.3/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.3 p1.1, pie-0.5.9' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --enable-lto --without-cloog --enable-libsanitizer
Thread model: posix
gcc version 4.8.3 (Gentoo 4.8.3 p1.1, pie-0.5.9) 

for those who are skeptic, the file is there:

ozn@yeni2gen:~$ ls -l hello32 
-rwxr-xr-x 1 ozn ozn 6825 May 31 19:04 hello32

Upvotes: 2

Views: 1057

Answers (1)

oz123
oz123

Reputation: 28838

OK, thanks for the hints. Apparently, I am doing something wrong with my gentoo. After digging a lot in the gentoo forums, and thanks for the hints here, I found a solution:

(root)# ln -vs /lib32/ld-linux.so.2 /lib/ld-linux.so.2

The original discussion in the gentoo forums which gave me this hint.

Upvotes: 1

Related Questions