Compile OpenSSL with the 'shared' option?

后端 未结 5 1211
逝去的感伤
逝去的感伤 2020-12-16 10:47

On CentOS 5.4, OpenSSL compiles fine without \'shared\' option. But when I passed that option the compilation fails with:

/usr/bin/ld: libcrypto.a(x86

相关标签:
5条回答
  • 2020-12-16 10:58

    There is an option -fXXX that you can pass to config so you can do it with:

    ./config -fPIC shared
    
    0 讨论(0)
  • 2020-12-16 11:17

    Same problem here, BUT usually Makefiles will consider environment variables for compiler or linker options.

    So, if you place the -fPIC option before calling the configure script, it should take care of it. You can do it with:

    CFLAGS=-fPIC ./config shared --prefix=/your/path
    

    or

    export CFLAGS=-fPIC
    ./config shared --prefix=/your/path
    

    It worked for me.

    0 讨论(0)
  • 2020-12-16 11:20

    The OpenSSL version 1.0 (published today) works fine with the shared option

    0 讨论(0)
  • 2020-12-16 11:22

    Here's how I built OpenSSL with shared libraries. Note that I'm using a cross compiler so I specify things most wouldn't.

    # hop into the downloads folder
    cd ~/Downloads
    # get the branch of openssl you want
    git clone -b OpenSSL_1_0_2-stable --single-branch https://github.com/openssl/openssl.git
    # make an installation directory
    mkdir openssl-install
    # go into the cloned openssl directory
    cd openssl
    # absolute paths needed for the configure
    # the "-fPIC -mhard-float" are CFLAGS specific to my project
    # the "-shared" is what creates the .so files
    # find your desired configuration with `./Configure LIST`
    ./Configure linux-mips32 --prefix=/home/myusername/Downloads/openssl-install --openssldir=/system/ssl -fPIC -mhard-float -shared
    # run the make file (with my specific compiler)
    make CC=mips-linux-gnu-gcc RANLIB=mips-linux-gnu-ranlib LD=mips-linux-gnu-ld MAKEDEPPROG=mips-linux-gnu-gcc PROCESSOR=MIPS
    
    0 讨论(0)
  • 2020-12-16 11:24

    Compiling openssl

    Download your openssl tarball, unzip, and then ensure that the install directory is named openssl.

    I placed mine in /usr/local/openssl, so I'll use that in my example.

    1. sudo mv openssl-1.0.2u /usr/local/openssl && cd /usr/local/openssl

    2. sudo make distclean

    3. sudo ./config -fPIC -shared

    4. sudo make && sudo install

      Now, add the openssl shared library to your PATH.

    5. vim ~/.profile Go export PATH="/usr/local/openssl/lib:$PATH" :wq

    0 讨论(0)
提交回复
热议问题