美文网首页
翻译:Compile program for 32bit on

翻译:Compile program for 32bit on

作者: 东东东东东东丶 | 来源:发表于2018-06-20 19:05 被阅读0次

    Stack overflow地址:Compile program for 32bit on 64bit Linux OS causes fatal error

    翻译:

    使用

    gcc -m32 myprog.c

    应该会编译 myprog.c文件的 32位版本。

    不幸的是我得到了这个错误:

    In file included from /usr/include/stdio.h:27:0,

                    from myprog.c:1:

    /usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory

    #include

    我应该怎么处理这个错误呢?

    如果我不使用 -m32,使用 64位的架构它会工作。


    Answers1:

    在64位Linux上编译32位的二进制程序,你需要安装 libx32gcc开发包和 32位的 GNU C库。

    尝试这样:

    sudo apt-get install libx32gcc-4.8-dev

    sudo apt-get install libc6-dev-i386


    Answers2:

    你需要gcc多库支持。安装 gcc-multilib包。比如:

    sudo apt-get install gcc-multilib


    Answers3:

    我遇到了一模一样的问题。我在 64位的乌班图上尝试遍历 32位的动态库文件。

    你可以通过选择你的库文件版本为64位(-> project properties -> C compiler-> additional options)

    -shared -m64


    Answers4:

    为了解决这个问题,我们首先需要知道那个包提供了 sys/cdefs.h这个文件。

    在基于 CentOs / RHEL的系统中,你可以运行下面的命令:

    yum provides '*sys/cdefs.h'

    同样的,在 Debian / Ubuntu系统中,你可以运行下面的命令来找:

    apt-file search 'sys/cdefs.h'

    注意:如果 apt-file不在现在的系统中,需要使用命令安装:

    apt-get install apt-file

    上面的两个命令都会扫描相应的包管理系统数据库。RPM/apt会告诉提供以“sys/cdefs.h”结尾的包名称。

    从命令列表中安装合适的包。

    就像:

    在 CentOs/RHEL:

    yum install glibc-headers

    在 Debian/Ubuntu:

    apt-get install libc6-dev

    这种方法并不只适用于这个特定的问题,还有类似的问题,哪些报告某些软件包提供某些文件不存在的问题也可以这么处理。

    相关文章

      网友评论

          本文标题:翻译:Compile program for 32bit on

          本文链接:https://www.haomeiwen.com/subject/xqnxyftx.html