【问题标题】:run a 32bit program on a 64bit gentoo linux在 64 位 gentoo linux 上运行 32 位程序
【发布时间】:2015-05-31 17:06:42
【问题描述】:

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

#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) 

对于那些持怀疑态度的人,该文件就在那里:

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

【问题讨论】:

  • 你能用ls看到预期目录下的文件吗?
  • 错误提示文件不在该目录中。
  • 您必须安装 32 位库。无法帮助您如何在 Gentoo Linux 上执行此操作。可能无法找到 /lib/ld-linux.so.2 导致 No such file or directory 消息。
  • 如果所需的库不存在,链接器不会失败吗?
  • ldd ./hello32 的输出是什么?

标签: c linux gentoo x86


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2010-10-18
    • 2012-03-12
    • 2015-06-20
    • 2011-11-02
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    相关资源
    最近更新 更多