如何在 64 位系统上以 32 位模式编译 openSSL?

发布于 2024-12-10 17:15:06 字数 159 浏览 0 评论 0原文

我有一个程序,目前必须在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

固执像三岁 2024-12-17 17:15:06

风滚草徽章提醒我自己回来回答!
我让它工作的方法是使用:

setarch i386 ./config -m32

The tumbleweed badge reminded me to come back and answer it myself!
The way I got this to work was to use:

setarch i386 ./config -m32
ペ泪落弦音 2024-12-17 17:15:06

对我来说不幸的是,setarch 在我的 LFS 系统上不是一个有效的命令,所以我必须以不同的方式来做:

./Configure shared threads zlib-dynamic --prefix=/usr --openssldir=/etc/ssl -m32 linux-generic32

注意:这是使其按照OP希望的方式工作的最小示例:

./Configure -m32 linux-generic32

Unfortunately for me, setarch was not a valid command on my LFS system, so I had to do it in a different way:

./Configure shared threads zlib-dynamic --prefix=/usr --openssldir=/etc/ssl -m32 linux-generic32

Note: this is the minimal example to make it work as OP wishes:

./Configure -m32 linux-generic32
岁月流歌 2024-12-17 17:15:06

我遇到了类似的问题,只是我尝试在 Solaris x86 机器上进行编译。 setarch 在 Solaris 中不可用,因此我无法使用此处其他答案之一中建议的更简单的方法。

OpenSSL 的“config”脚本是一个 shell 包装器,它确定它认为的目标系统,然后调用“Configure”perl 脚本,该脚本完成繁重的工作。配置有很多内置目标:您可以使用“perl 配置表”来获取所有目标的列表。这是从可用列表中选择您需要的目标的情况。

因此,如果您想强制它构建除它认为应该构建的目标之外的目标,您可以直接调用“Configure”,并传递所需目标的名称。例如,为了让我的 Solaris 32 位版本正常工作,我使用了:

./Configure solaris-x86-cc --shared

或者,对于最初的问题,如果它是 Linux 系统,您可以使用:

./Configure linux-generic32 --shared

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:

./Configure solaris-x86-cc --shared

or, in the case of the original question, if it was a Linux system you could use:

./Configure linux-generic32 --shared
幸福丶如此 2024-12-17 17:15:06

为了在 Centos 5 x64 上进行 32 位编译,我必须同时执行 setarch-m32,并安装 的 32 位开发包glibc。

setarch i386 ./Configure --prefix=/usr linux-generic32 -m32 shared
sudo yum install glibc-devel-2.5-118.el5_10.2.i386
make

作为测试以确保,使用 file 命令查看结果是什么

file libcrypto.so.0.9.8 libssl.so.0.9.8
libcrypto.so.0.9.8: ELF **32-bit** LSB shared object, Intel 80386, version 1 (SYSV), not stripped
libssl.so.0.9.8:    ELF **32-bit** LSB shared object, Intel 80386, version 1 (SYSV), not stripped

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 for glibc.

setarch i386 ./Configure --prefix=/usr linux-generic32 -m32 shared
sudo yum install glibc-devel-2.5-118.el5_10.2.i386
make

as a test to make sure, use file command to see what the results are

file libcrypto.so.0.9.8 libssl.so.0.9.8
libcrypto.so.0.9.8: ELF **32-bit** LSB shared object, Intel 80386, version 1 (SYSV), not stripped
libssl.so.0.9.8:    ELF **32-bit** LSB shared object, Intel 80386, version 1 (SYSV), not stripped

Bingo!

月亮邮递员 2024-12-17 17:15:06

运行 ./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 then make 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.

绝影如岚 2024-12-17 17:15:06

可能可以修改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";;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文