在64位gentoo linux上运行32位程序

时间:2015-05-31 17:06:43

标签: c linux gentoo ia-32

我在64位gentoo上运行32位代码时遇到困难,程序非常简单:

 destinationGeocoder.geocode( { 'address': destination }, function(results, status) {
        var addr_type = results[0].types[0];    // type of address inputted that was geocoded
        if ( status == google.maps.GeocoderStatus.OK ) 
            ShowLocation( results[0].geometry.location, destination, addr_type );
        else     
            alert("Geocode was not successful for the following reason: " + status);        
    });

我用#include <stdio.h> main() { printf("Hello World"); } 编译了它。输出似乎是正确的:

gcc -m32 -o hello32 hello.c

但是当我尝试运行该文件时出现错误:

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

更新

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

对于那些怀有疑虑的人,文件就在那里:

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) 

1 个答案:

答案 0 :(得分:1)

好的,谢谢你的提示。显然,我的gentoo做错了。在gentoo论坛中挖掘了很多东西后,感谢这里的提示,我找到了一个解决方案:

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

original discussion in the gentoo forums给了我这个提示。