如何在Linux上编译以与所有发行版共享? [英] How do I compile on linux to share with all distributions?

查看:102
本文介绍了如何在Linux上编译以与所有发行版共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Fedora Core 12上编译了一个PHP扩展,但是当我使用CentOS将其发送给某人时,他们会收到错误消息:"ELF文件OS ABI无效"

I compiled a PHP extension on Fedora Core 12, but when I send it to someone using CentOS they get the error: "ELF file OS ABI invalid"

我不确定是什么原因导致此运行文件提供以下信息: 未剥离的ELF 64位LSB共享对象,AMD x86-64,版本1(GNU/Linux)

I'm not sure what causes this running file provides the following info: ELF 64-bit LSB shared object, AMD x86-64, version 1 (GNU/Linux), not stripped

可以很好地从文件中加载以下内容的扩展程序: ELF 64位LSB共享对象,AMD x86-64,版本1(SYSV),未剥离

An extension that loads fine provides the following from file: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

所以看来我需要为某些发行版生成SYSV类型的文件,而不是GNU/LINUX文件,但不知道如何.有指针吗?

So it seems I need to generate a SYSV type file for some distributions, instead of a GNU/LINUX file, no idea how though. Any pointers?

我还应该静态链接吗?

推荐答案

语句:"ELF文件OS ABI无效",表示应用程序二进制接口在使用的二进制文件之间不兼容(即,正在尝试混合主机二进制文件和目标二进制文件, 可能无法正常工作). e_ident[EI_OSABI] 字节="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format" rel ="nofollow noreferrer"> ELF 标头包含操作系统/ABI标识.您的Fedora系统将其设置为ELFOSABI_LINUX(3),而您朋友的CentOS系统将其设置为ELFOSABI_SYSV(ELFOSABI_NONE0).

The statement: "ELF file OS ABI invalid", means that the Application Binary Interface is non compatible between binaries used (i.e. one is trying to mix host and target binaries, which may not work as expected). The e_ident[EI_OSABI] byte of the ELF header contains the operating system/ABI identification. Your Fedora system is setting this to ELFOSABI_LINUX (3) while your friend's CentOS system is setting it to ELFOSABI_SYSV (ELFOSABI_NONE or 0).

也许能够编译FreeBSD brandelf实用程序(

You may be able to compile the FreeBSD brandelf utility (brandelf.c) and use it to set the OSABI to ELFOSABI_SYSV (brandelf -f 0 <file> or brandelf -t SVR4 <file>.

我不知道在编译/链接时用于指定此值的任何gcc标志.我相信Fedora系统上gcc使用的binutils版本负责将OSABI设置为Linux.据我了解,链接器仅在输出文件中出现STT_GNU_IFUNC符号结尾时指定ABI(请参见

I am not aware of any gcc flags for specifying this value at compile/link time. I believe that the version of binutils used by gcc on your Fedora system is responsible for setting the OSABI to Linux. It is my understanding that the linker only specifies the ABI if a STT_GNU_IFUNC symbol ends up in the output file (see ifunc.txt at http://groups.google.com/group/generic-abi for details on STT_GNU_IFUNC).

readelf(1)命令可用于检索和显示ABI存储在ELF标头(readelf -h <file>)中的信息.

The readelf(1) command can be used to retrieve and display the ABI information stored in the ELF header (readelf -h <file>).

类似的问题也可能很有趣.

这篇关于如何在Linux上编译以与所有发行版共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆