Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile openSSL in 32 bit mode on a 64bit system?

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.

like image 997
Gary Barker Avatar asked Oct 20 '11 11:10

Gary Barker


3 Answers

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
like image 81
Gary Barker Avatar answered Oct 15 '22 13:10

Gary Barker


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
like image 19
Iskren Avatar answered Oct 15 '22 12:10

Iskren


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
like image 7
harmic Avatar answered Oct 15 '22 13:10

harmic