40

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.

Gary Barker
  • 1,609
  • 2
  • 15
  • 18

6 Answers6

36

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
Gary Barker
  • 1,609
  • 2
  • 15
  • 18
21

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
Ðаn
  • 10,934
  • 11
  • 59
  • 95
Iskren
  • 1,301
  • 10
  • 15
8

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
harmic
  • 28,606
  • 5
  • 67
  • 91
4

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!

prajmus
  • 3,171
  • 3
  • 31
  • 41
Rmolinger
  • 41
  • 1
1

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.

D3Hunter
  • 1,329
  • 10
  • 21
0

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";;