Skip navigation.
Home

Compile OpenSSL as 32bit shared library on Solaris

  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dopey/cozmanova.com/includes/unicode.inc on line 345.

With version 10, Solaris provides a solid platform for Open Source applications, by providing a load of precompiled and preinstalled tools and libraries in /usr/sfw ; still, sometimes you want to use your own compiled version. For example, I think everybody should use their own compiled OpenSSL instead of pre-fabricated binaries. But trying to compile OpenSSL can sometimes make you go mad...

Some of the errors that you can expect, when you're not doing everything right, could be:

* cryptlib.c:1: sorry, unimplemented: 64-bit mode not compiled in

* segmentation faults when running 'make test' after a seemlingly succesfull build

* make: Fatal error: Command failed for target `libcrypto.so.0.9.8'

* ld: fatal: file wrong ELF class: ELFCLASS64 - when trying to link against a seeminly succesfull openssl library

* EVP_CIPHER_CTX_block_size ext/openssl/.libs/openssl.o - when trying to link against a seeminly succesfull openssl library

There are plenty of things that can and will go wrong. One of the reasons, is that you do not want to have a 64bit library to link against, as most of the applications you will be using, cannot use 64bits libraries. Yet?...
The instructions offer guidance to using GnuCC (gcc) and its tools to actually build the openssl library, using version 0.9.8l (5 nov 2009 version).

Before moving on, make sure that you have installed a recent version of at least
- gcc (you can get it from www.sunfreeware.com to install in /usr/local/bin)
- binutils (checkout www.sunfreeware.com)

Here are some instructions that can lead to a succesfull result (I did everything as root-user...)

1) Make sure your environment PATH is ok
This means that the gnu compilers are first in the path:


# export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/ssl/bin:/usr/sfw/sbin/:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/ccs/bin

2) Set up the runtime link environment; this is something that you should explicitly do to make sure that the -R arguments are passed to the compiler; as such, it is critical:


# PREFIX=openssl-0.9.8l
# export LD_OPTIONS="-R/usr/local/${PREFIX}/lib"

3) We are building a 32-bits version; force Configure to do so as we are on a 64bit platform:


# ./Configure solaris-x86-gcc --prefix=/usr/local/${PREFIX} shared -R/usr/local/${PREFIX}/lib

4) This is something I am not sure about what is the right way to solve yet, but set the LD_LIBRARY_PATH to include the gcc-versions of the libraries that will be linked against; prioritize to first try to use the gcc-versions, the rest later


# export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib

5) Do build:


# make
# make test
# make install

6) To complete, I created a symlink in /usr/local, so this ssl-build can be referenced to by using /usr/local/ssl:


# cd /usr/local
# ln -s openssl-0.9.8l ssl

7) This works for me, except that the LD_LIBRARY_PATH *must* be set to use /usr/local/ssl/openssl or tools that are linked against openssl (like php's cli); I enforced this in an ugly but effective way, by adding

export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib

to /etc/profile.

Suggestions how to improve this are welcome.

Good luck; this has cost me some considerable amounts of time to work out!