如何在 64 位系统上以 32 位模式编译 openSSL?
我有一个程序,目前必须在 32 位模式下编译(暂时),并且需要与包含实验密码的 openSSL 版本链接。因此我需要编译一个32位的openSSL。使用
./config -m32
-m32 和 -m64 的结果都包含在编译器标志中。
I have a program that currently has to be compiled in 32 bit mode (for now) and needs to be linked against a version of openSSL with the experimental ciphers included. Therefore I need to compile a 32 bit openSSL. Using
./config -m32
results in both -m32 and -m64 being included in the compiler flags.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
风滚草徽章提醒我自己回来回答!
我让它工作的方法是使用:
The tumbleweed badge reminded me to come back and answer it myself!
The way I got this to work was to use:
对我来说不幸的是,setarch 在我的 LFS 系统上不是一个有效的命令,所以我必须以不同的方式来做:
注意:这是使其按照OP希望的方式工作的最小示例:
Unfortunately for me, setarch was not a valid command on my LFS system, so I had to do it in a different way:
Note: this is the minimal example to make it work as OP wishes:
我遇到了类似的问题,只是我尝试在 Solaris x86 机器上进行编译。 setarch 在 Solaris 中不可用,因此我无法使用此处其他答案之一中建议的更简单的方法。
OpenSSL 的“config”脚本是一个 shell 包装器,它确定它认为的目标系统,然后调用“Configure”perl 脚本,该脚本完成繁重的工作。配置有很多内置目标:您可以使用“perl 配置表”来获取所有目标的列表。这是从可用列表中选择您需要的目标的情况。
因此,如果您想强制它构建除它认为应该构建的目标之外的目标,您可以直接调用“Configure”,并传递所需目标的名称。例如,为了让我的 Solaris 32 位版本正常工作,我使用了:
或者,对于最初的问题,如果它是 Linux 系统,您可以使用:
I had a similar problem, except I was trying to compile on a Solaris x86 machine. setarch is not available in Solaris, so I could not use the simpler approach suggested in one of the other answers here.
The 'config' script for OpenSSL is a shell wrapper which determines what it thinks is the target system, then calls the 'Configure' perl script, which does the heavy lifting. Configure has a lot of built in targets: you can use 'perl Configure TABLE' to get a list of all of them. It is a case of selecting the target you need from the available list.
So, if you want to force it to build for a target other than the one it thinks you should, you can call 'Configure' directly, passing the name of the target you want. For example, to get my Solaris 32 bit build to work, I used:
or, in the case of the original question, if it was a Linux system you could use:
为了在 Centos 5 x64 上进行 32 位编译,我必须同时执行
setarch
和-m32
,并安装的 32 位开发包glibc。
作为测试以确保,使用 file 命令查看结果是什么
Bingo!
In order to get the 32 bit compile working on Centos 5 x64 I had to do both
setarch
and-m32
, as well as install the 32 bit devel package forglibc
.as a test to make sure, use file command to see what the results are
Bingo!
运行
./Configure linux-generic32
,然后make CC="gcc -m32"
在 CentOS-5.5 64 位版本上编译 Openssl-1.0.0.c 时对我有用。至于如何在 64 位计算机上构建 32b 应用程序,请检查 this,它给出了如何在各种平台上安装必要的32位头文件和库的详细步骤。
Run
./Configure linux-generic32
and thenmake CC="gcc -m32"
works for me when compiling Openssl-1.0.0.c on CentOS-5.5 64bit version.As of how to build 32b application on 64bit machine, check this, which gives detailed steps on how to install necessary 32bit header files and libraries on various platform.
可能可以修改openssl中的“config”文件,因为它会首先检查操作系统是64位还是32位,并为操作系统准备配置,例如操作系统是64位,我们可以将config中的术语修改为以下
替换 x86_64--linux?) OUT="linux-x86_64";;
与 x86_64--linux?) OUT="linux-generic32";;
May be will can modify "config" file in openssl,because it will first check the OS 64 bit or 32 bit ,and the prepare the configure for OS,for example,the OS is 64bit,and we can modify the term in config as below
repace x86_64--linux?) OUT="linux-x86_64";;
with x86_64--linux?) OUT="linux-generic32";;