December 8, 2010

Compile Openssl for Linux MIPS

1. Grab openssl source 1.0.c
2. Grab the Linux-MIPS patch at http://svn.cross-lfs.org/svn/repos/patches/openssl/openssl-0.9.8k-mips_support-1.patch
3. apply the patch: the patch basically just add a few lines to the Configure file. you can do that manually if you want.
4. CC=YOUR-MIPS-CC ./configure linux-mips  (add "shared" if you want to build shared library)
5. make

7 comments:

  1. Hi,
    First of all thanks for this post. I tried your steps. But I am getting this error:

    make[2]: *** No rule to make target `-fPIC', needed by `lib'. Stop.

    Anything I could miss?

    Thanks,
    -Andrei

    ReplyDelete
  2. There is an error in Makefile of crypto/modes:
    at line 26-27
    LIBOBJ= cbc128.o ctr128.o cts128.o cfb128.o ofb128.o gcm128.o \
    ccm128.o xts128.o $(MODES_ASM_OBJ)
    MODES_ASM_OBJ=fPIC and shouldn't be there since it is not a target but a compile options.
    I removed $(MODES_ASM_OBJ) and it worked.

    ReplyDelete
    Replies
    1. Awesome! It worked for me! Thanks!

      -Andrei

      Delete
  3. Compiling openssl 1.0.1e for linux-mips


    wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
    tar xvzf openssl-1.0.1e.tar.gz
    cd openssl-1.0.1e

    # with no asm optimization

    sed -i '/^# uClinux/i\
    "linux-mips", "gcc:-DB_ENDIAN -DTERMIO -O3 -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\\$(SHLIB_MAJOR).\\$(SHLIB_MINOR)",' Configure

    # with MIPS32 asm optimization

    sed -i '/^# uClinux/i\
    "linux-mips", "gcc:-DB_ENDIAN -DTERMIO -O3 -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\\$(SHLIB_MAJOR).\\$(SHLIB_MINOR)",' Configure

    ./Configure linux-mips --openssldir=$SYSROOT/etc/ssl --prefix=$SYSROOT/usr \
    -DOPENSSL_SMALL_FOOTPRINT shared
    make CC=$PREFIX/bin/mips-linux-uclibc-gcc
    make CC=$PREFIX/bin/mips-linux-uclibc-gcc -i install

    ReplyDelete
  4. I have used this particular configuration -
    +"linux-mips64", "gcc:-mabi=64 -DB_ENDIAN -DTERMIO -O3 -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2::::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",

    The compilation goes on fine for static library libcrypto.a
    When i try to build libcrypto.so (shared library) by specifying shared option:

    ./Configure shared linux-mips64

    I get this message

    Configured for linux-mips64.

    You gave the option 'shared'. Normally, that would give you shared libraries.
    Unfortunately, the OpenSSL configuration doesn't include shared library support
    for this platform yet, so it will pretend you gave the option 'no-shared'. If
    you can inform the developpers (openssl-dev\@openssl.org) how to support shared
    libraries on this platform, they will at least look at it and try their best
    (but please first make sure you have tried with a current version of OpenSSL).


    Any idea what needs to be done here?

    ReplyDelete
  5. This patch works perfectly for linux-mips64 compilation.

    ReplyDelete
  6. I facing problem while compiling openssl library for mipsel-linux-gcc. From your post looks like you are able to build.
    Please help how to build it?

    I took the source code of openssl from 'https://github.com/openssl/openssl'

    And also when i am accessing for link 'http://svn.cross-lfs.org/svn/repos/patches/openssl/openssl-0.9.8k-mips_support-1.patch' it showing 404 error.

    Please provide me the patch file and necessary steps for successful compilation.


    Thanks in Advance,
    Pravallika KG

    ReplyDelete